473,378 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Converting Hex String to Bmp file

hie Team.

here is my scenario:

1. i managed to convert a bmp image file to hex and then sending it to a server.
see the following code
Expand|Select|Wrap|Line Numbers
  1. fp = fopen("\\C\\photo.bmp","rb");
  2.             fseek(fp,0,SEEK_END); //go to end
  3.             PicLen = ftell(fp); //get position at end (length)
  4.             PICBuffer = (byte *)malloc(PicLen); //malloc buffer
  5.             fseek(fp,0,SEEK_SET); //go to beg.
  6.             fread(PICBuffer,PicLen,1,fp); //read into buffer
  7.             fclose(fp);
  8.             i=0;
  9.  
  10.             do
  11.             {
  12.  
  13.                 sprintf(temp,"%02x",PICBuffer[i]);
  14.                 strcat(ReqInfo.Pic,temp);
  15.                 i+=1;
  16.  
  17.             }
  18.             while(i<PicLen);
  19.  
2. now the server is returning back those hex values and i want to convert them back to the original bmp image file.



Thanks in advance
Nov 2 '11 #1
2 4760
johny10151981
1,059 1GB
Do you really know how you converted from BMP to Hexa value??

Extracting will be follow the same rule
Nov 3 '11 #2
johny10151981:

yes i do. I am actually converting it back to a BMP image, but my picture doesnt look good at all, when i compare the hex values of my original picture and the one i create when i convert from hex to BMP, there is this "D0D0" in my converted output picture.

i think im not writinhg it correctly:

see illustration below, i have extractracted the first few hex values for the two pictures:

original picture hex values:
FFD8FFE000104A46494600010100000100010000FFDB004300 100B0C0E0C0A100E0D0E1211101318281A181616183123251D 283A333D3C3933383740485C

my converted picture hex values:
FFD8FFE000104A46494600010100000100010000FFDB004300 100B0C0E0C0D0D0A100E0D0E1211101318281A181616183123251D283A333D3C3 9

can you see the D0D0 values in the second one.

thanks
Nov 4 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Hal Vaughan | last post by:
If I have a byte and I convert it to string (String sData = new String(byte bData), then convert it back (byte bData = sData.getBytes()), will all data be intact, or do Strings have problems with...
5
by: Laughlin, Joseph V | last post by:
class Foo: x = "blah" y = "blah some more" foo = Foo() x_string = "x" y_string = "y" # I want something like this to work: print foo.x_string
4
by: rainmaker1234 | last post by:
Its very simple in VC++. In the followeing code I have declared a String, and a double than I am taking the string and converting it into Double. getch() at the end is only to pause the screen so...
5
by: vivekaseeja | last post by:
Hi , Trying to convert a string value to a float value after reading the value from an XML file , but not sure what function to use. The following only works for integers Int32.Parse...
4
by: Samuel Hardman | last post by:
Hello, I am trying to write a perl script to parse a string into an array. The string has the fields separated by tabs. So what I want to do is read each field into a variable so I can process...
5
by: SMichal | last post by:
Hi, how can I parse string "? 20.000" to double ?
3
by: manigattani | last post by:
Please let me know of some java code for converting dbf file to text file
3
by: Rory Becker | last post by:
The following code is being used in a VB6 program to read and write a simple binary file. I need to move things into the 21st century and recode this in VB.Net The new VB.Net program will need...
3
by: kronus | last post by:
I'm receiving an xml file that has a child called modified and it represents a date value in the form of a string -- Nov 14, 2008 -- and in my app, I have items associated with each object and I'm...
1
zabsmarty
by: zabsmarty | last post by:
I need a help when, converting video file into flv and add site domain name into video, when any one play the video than the domain name display the the video when it play.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.