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

C / C++ / MFC

 
AnswerRe: How to convert an array of 32bit integers to image in C++ Pin
Code-o-mat6-Jul-09 5:08
Code-o-mat6-Jul-09 5:08 
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 
The color imformation looks very different in the DIB which i have generated. I am not sure if i should use some color palette. Please find below the code which i used
        HDC dc= CreateCompatibleDC(NULL);
BITMAPINFO info;
ZeroMemory( &info.bmiHeader, sizeof (BITMAPINFOHEADER) );
info.bmiHeader.biHeight = 1002;
info.bmiHeader.biWidth = 1004;
info.bmiHeader.biPlanes = 1;
info.bmiHeader.biBitCount = 24;
info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
info.bmiHeader.biClrUsed= 0;
info.bmiHeader.biClrImportant= 0;
long* pixels;
int Buffersize = 1004*1002;

HBITMAP hbmp= CreateDIBSection( dc,
&info,
DIB_RGB_COLORS,
(void**)&pixels,
NULL,
0 );

pixels = (long*) malloc(Buffersize*sizeof(long));
        //arr contains pixels data (32bit unsigned integers)
for(int j=0; j < Buffersize; j++)
{
    pixels[j] = arr[j];
}

int nFile = _open ("c:\\Image.bmp", _O_CREAT | _O_TRUNC | _O_BINARY | _O_WRONLY, _S_IWRITE);

int nBitmapDataSize = (width * height * 3);
int nFileSize = sizeof (BITMAPFILEHEADER) + sizeof       (BITMAPINFOHEADER) + nBitmapDataSize;
int nOffset = sizeof (BITMAPFILEHEADER) + sizeof (BITMAPINFOHEADER);

BITMAPFILEHEADER bmfh;
bmfh.bfType = ((WORD) ('M' << 8) | 'B');
bmfh.bfSize = nFileSize;
bmfh.bfReserved1 = 0;
bmfh.bfReserved2 = 0;
bmfh.bfOffBits = nOffset;

BITMAPINFOHEADER bmih;
memset (&bmih, 0, sizeof (BITMAPINFOHEADER));
bmih.biSize = sizeof (BITMAPINFOHEADER);
bmih.biPlanes = 1;
bmih.biBitCount = 24;
bmih.biCompression = BI_RGB;
bmih.biWidth = width;
bmih.biHeight = height;

_write (nFile, &bmfh, sizeof (BITMAPFILEHEADER));
_write (nFile, &bmih, sizeof (BITMAPINFOHEADER));
_write (nFile, pixels, nBitmapDataSize);
_close (nFile);

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 
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 

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.