Click here to Skip to main content
15,889,595 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
su_marvel7-Jul-09 1:06
su_marvel7-Jul-09 1:06 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
chandu0047-Jul-09 1:16
chandu0047-Jul-09 1:16 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
su_marvel7-Jul-09 1:54
su_marvel7-Jul-09 1:54 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
Code-o-mat7-Jul-09 1:34
Code-o-mat7-Jul-09 1:34 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
su_marvel7-Jul-09 3:56
su_marvel7-Jul-09 3:56 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
Code-o-mat7-Jul-09 4:01
Code-o-mat7-Jul-09 4:01 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
su_marvel7-Jul-09 4:21
su_marvel7-Jul-09 4:21 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
Code-o-mat7-Jul-09 4:54
Code-o-mat7-Jul-09 4:54 
What are you trying to achieve here? If you wish to save your image you don't need a DIB section, i thought you wanted to display the image on some window for example, for that you could use the DIB, to save a bitmap to a file you can simply write the headers and the pixel data as you did without any device contexts or HBITMAPs. So let's forget the DIB and consider you just want to save the data to a bmp file. Explain what you mean by "looks very different". You should know that in a bitmap each scanline's bytecount has to be dividable by 4 otherwise your image will look disorted. To explain what i mean: you say your image's width is 1002 pixels. If you want a 24 bits per pixel bitmap, then every pixel is 3 bytes, right? So 1002 pixels is 1002 * 3 = 3006 bytes. 3006 / 4 = 751.5, so your scanlines do not occupy a multitple of 4 bytes. You need padding to overcome this, you have to add zeros to the end of each scanline till your scanline's bytecount can be divided by 4. So after you write 3006 bytes into the file for the RGB data you also need to write 2 additional bytes of 0, this way your scanlines will have 3008 bytes, which can be divided by 4 (752). You have to do this for each scanline. You should read about the bitmap file format here[^] or just google[^] a bit around.
Imho, you are better of trying to save a 32 bpp bitmap, since 32 bits are 4 bytes, your 1002 pixels on a scanline will occuppy 4008 bytes which is -obviously- dividable by 4.

> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <

GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
su_marvel7-Jul-09 5:06
su_marvel7-Jul-09 5:06 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
Code-o-mat7-Jul-09 5:33
Code-o-mat7-Jul-09 5:33 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
su_marvel7-Jul-09 22:11
su_marvel7-Jul-09 22:11 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
Code-o-mat7-Jul-09 23:31
Code-o-mat7-Jul-09 23:31 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
su_marvel8-Jul-09 3:36
su_marvel8-Jul-09 3:36 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
Code-o-mat8-Jul-09 5:11
Code-o-mat8-Jul-09 5:11 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
su_marvel8-Jul-09 22:21
su_marvel8-Jul-09 22:21 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
Code-o-mat8-Jul-09 22:28
Code-o-mat8-Jul-09 22:28 
AnswerRe: How to convert an array of 32bit integers to image in C++ Pin
Adam Roderick J6-Jul-09 5:27
Adam Roderick J6-Jul-09 5:27 
GeneralRe: How to convert an array of 32bit integers to image in C++ Pin
su_marvel7-Jul-09 1:01
su_marvel7-Jul-09 1:01 
QuestionHow to differenciate? Pin
FISH7866-Jul-09 3:20
FISH7866-Jul-09 3:20 
AnswerRe: How to differenciate? Pin
Stuart Dootson6-Jul-09 4:04
professionalStuart Dootson6-Jul-09 4:04 
GeneralRe: How to differenciate? Pin
FISH7866-Jul-09 4:11
FISH7866-Jul-09 4:11 
Questionunknown size of void * Pin
liquid_6-Jul-09 3:02
liquid_6-Jul-09 3:02 
AnswerRe: unknown size of void * Pin
Cedric Moonen6-Jul-09 3:07
Cedric Moonen6-Jul-09 3:07 
AnswerRe: unknown size of void * Pin
Adam Roderick J6-Jul-09 5:33
Adam Roderick J6-Jul-09 5:33 
AnswerRe: unknown size of void * Pin
TheGreatAndPowerfulOz6-Jul-09 10:49
TheGreatAndPowerfulOz6-Jul-09 10:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.