473,545 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem encoding/decoding image

Hi,

I'm trying to use POST an image to a web page with WebRequest/WebResponse.
Only problem is that I must be making an error somewhere in the
encoding/decoding process. I've pasted below a bit of sample code that
basically shows how I am encoding and then decoding the binary image. Many
thanks if you can point out what I am doing wrong... thanks, Slade Smith
Image bmp =context.GetIma ge();
Stream stream=new MemoryStream();

//save image as a jpg file. "test.jpg" will open fine when I try it....
bmp.Save("c:\\t emp\\test.jpg", System.Drawing. Imaging.ImageFo rmat.Jpeg);
bmp.Save(stream ,System.Drawing .Imaging.ImageF ormat.Jpeg);

//encode the image to prepare it for a transfer via a POST
int imgLen = (int)stream.Len gth;
byte[] imgBinaryData = new byte[imgLen];
int n = stream.Read(img BinaryData,0,im gLen);
string s = Convert.ToBase6 4String(imgBina ryData);

//I will be uploading the file here, and the code after this
//will be running on the server...

//trying just to reverse the encoding process and save the file,
//but something has gone horribly wrong, and none of my imaging
//programs will open "test2.jpg" when I try it. Must be corrupted.
imgBinaryData=C onvert.FromBase 64String(s);
Stream f=File.Create(" c:\\temp\\test2 .jpg");
imgLen = imgBinaryData.L ength;
f.Write(imgBina ryData,0,imgLen );
f.Close();
Nov 17 '05 #1
1 2670
Hi,

Refer to :
http://www.c-sharpcorner.com/Interne...esponseMDB.asp

Using WebClient make it more easier.

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3033
by: Matthias Stern | last post by:
Hello! I've got a Javascript-PHP encoding problem. (1) Here is the short version: ============================== I'm sending a form textfield via Javascript(!) as URL parameter (GET) from one php-page to another and want to send all possible special
3
5360
by: dot | last post by:
Hi all, I have written a Python huffman Encoding Module, for my own amusement. I thought it might be educational/entertaining for other people, so I've put it on my website and wrote about it a little. http://gumuz.looze.net/wordpress/index.php/archives/2004/11/25/huffman-encoding/ Your comments are highly appreciated! cheers,
8
6102
by: timtos | last post by:
I want to save text in a file and after that I want to display this textfile using the internet explorer. If I am displaying "html text" everything is fine but if I want to display plain text all characters from the extended ascii are looking weird - are not properly encoded! Using the options in View -> Encoding -> ... in the internet...
16
4876
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by Microsoft must be installed on their servers. Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses. This can be...
5
3645
by: philip | last post by:
Here is some lines of code than I wrote. You can copy/paste theis code as code of form1 in a new project. My problem is this one : I try to write in a file a serie of bytes. BUT some bytes written in file are not the sent bytes. Copy and paste the following lines to observe my problem. What can I do to resolve problem ? Only...
9
8789
by: KWSW | last post by:
Having settled the huffman encoding/decoding and channel modeling(thanks to the previous part on bitwise operation), the last part would be hamming encoding/decoding. Did some research as usual on hamming codes and how they work(well sort of) I got a general idea how to start constucting a (7,4) hamming code. Unfortunately I have no idea how...
0
2034
by: Independent | last post by:
Python programmers may find the application to decoding an encrypted map image format known as Memory Map to produce a standard PNG image file interesting. Someone obviously very well versed in Python and in the intricacies of image files has written a routine to decode originally the UK Landranger maps, so that they can be used with other...
0
3343
by: james.duckworthy | last post by:
Python programmers may find the application to decoding an encrypted map image format known as Memory Map to produce a standard PNG image file interesting. Someone obviously very well versed in Python and in the intricacies of image files has written a routine to decode originally the UK Landranger maps, so that they can be used with...
0
1806
by: Michele | last post by:
Hi there, I'm using a python script in conjunction with a JPype, to run java classes. So, here's the code: from jpype import * import os import random import math import sys
0
7410
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7923
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4960
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3466
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1025
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.