Click here to Skip to main content
15,922,894 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: A good book to learn about displaying images with MFC? Pin
csmithmaui25-Aug-06 17:16
csmithmaui25-Aug-06 17:16 
Questiondrawing in a dib file Pin
hugoiko25-Aug-06 16:05
hugoiko25-Aug-06 16:05 
AnswerRe: drawing in a dib file Pin
Dave Calkins25-Aug-06 16:17
Dave Calkins25-Aug-06 16:17 
GeneralRe: drawing in a dib file Pin
hugoiko26-Aug-06 14:02
hugoiko26-Aug-06 14:02 
GeneralRe: drawing in a dib file Pin
Dave Calkins26-Aug-06 17:44
Dave Calkins26-Aug-06 17:44 
GeneralRe: drawing in a dib file Pin
hugoiko27-Aug-06 11:53
hugoiko27-Aug-06 11:53 
GeneralRe: drawing in a dib file Pin
Dave Calkins27-Aug-06 12:38
Dave Calkins27-Aug-06 12:38 
GeneralRe: drawing in a dib file Pin
hugoiko27-Aug-06 13:58
hugoiko27-Aug-06 13:58 
I finally got it to, but i dont really know how. Now my code look like this and it saves a beautiful fractal image. Maybe my alignement issue was just a syntax error :s... but... I wonder where is the byte alignement in this code ...??? I'm computing each point at a time, and I write 3 BYTEs (for R , G, B) in a byte array, then i write the whole thing in the file.

int xsize = 1000;
int ysize = 1000;

BYTE* a = new BYTE[xsize*ysize*4*3];

int smaller;
if (ysize < xsize)
smaller = ysize;
else
smaller = xsize;

double value = 1/double(smaller);
for(int y = -ysize; y < ysize; ++y){
for(int x = -xsize; x < xsize; ++x){
double realx = double(x)*value;
double realy = double(y)*value;
int iteration = Mandelbrot( realx, -realy, 1024);
COLORREF color;
color = ColorSelector(iteration,0,512,


0,true,0,255,0);
a[((y+ysize)*(xsize*2)+(x+xsize))*3] = GetBValue(color);
a[((y+ysize)*(xsize*2)+(x+xsize))*3+1] = GetGValue(color);
a[((y+ysize)*(xsize*2)+(x+xsize))*3+2] = GetRValue(color);


}
}

BITMAPFILEHEADER hdr;
BITMAPINFOHEADER bi;


CFile file;
file.Open( "C:\\test.dib", CFile::modeWrite|CFile::modeCreate);

bi.biBitCount = 24;
bi.biClrImportant = 0;
bi.biClrUsed = 0;
bi.biCompression = BI_RGB;
bi.biHeight = -ysize*2;
bi.biPlanes = 1;
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biSizeImage = 0;
bi.biWidth = xsize*2;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;

hdr.bfType= ((WORD) ('M' << 8) | 'B');
hdr.bfSize= sizeof(bi) + sizeof(hdr);
hdr.bfReserved1 = 0;
hdr.bfReserved2 = 0;
hdr.bfOffBits= (DWORD) (sizeof(hdr) + bi.biSize);

file.Write( &hdr, sizeof(hdr) );

file.Write( &bi, sizeof(bi) );

file.Write( a, sizeof(BYTE)*xsize*ysize*4*3 );

file.Close();

I would like to try the CImage trick, cause i don't feel 100% confortable manually playing with bytes... but is it a .NET feature? Cause im still using VC6.
AnswerRe: drawing in a dib file Pin
Hamid_RT28-Aug-06 7:11
Hamid_RT28-Aug-06 7:11 
QuestionEnter Key killing my dialog [modified] Pin
Ger Hayden25-Aug-06 13:17
Ger Hayden25-Aug-06 13:17 
AnswerRe: Enter Key killing my dialog Pin
RChin25-Aug-06 14:16
RChin25-Aug-06 14:16 
AnswerRe: Enter Key killing my dialog Pin
Justin Tay25-Aug-06 14:21
Justin Tay25-Aug-06 14:21 
Questionthe : operator Pin
Waldermort25-Aug-06 13:10
Waldermort25-Aug-06 13:10 
AnswerRe: the : operator Pin
BadKarma25-Aug-06 13:29
BadKarma25-Aug-06 13:29 
GeneralRe: the : operator Pin
Waldermort25-Aug-06 13:44
Waldermort25-Aug-06 13:44 
GeneralRe: the : operator Pin
Justin Tay25-Aug-06 13:54
Justin Tay25-Aug-06 13:54 
GeneralRe: the : operator Pin
BadKarma25-Aug-06 14:02
BadKarma25-Aug-06 14:02 
GeneralRe: the : operator [modified] Pin
Waldermort25-Aug-06 14:16
Waldermort25-Aug-06 14:16 
QuestionSkinning Pin
BlitzPackage25-Aug-06 12:07
BlitzPackage25-Aug-06 12:07 
AnswerRe: Skinning Pin
Mircea Puiu26-Aug-06 20:22
Mircea Puiu26-Aug-06 20:22 
QuestionSHFileOperation is pissing me off - won't copy just 1 file Pin
AceCoolie25-Aug-06 11:36
AceCoolie25-Aug-06 11:36 
AnswerRe: SHFileOperation is pissing me off - won't copy just 1 file Pin
Waldermort25-Aug-06 13:12
Waldermort25-Aug-06 13:12 
GeneralRe: SHFileOperation is pissing me off - won't copy just 1 file Pin
AceCoolie26-Aug-06 4:48
AceCoolie26-Aug-06 4:48 
AnswerRe: SHFileOperation is pissing me off - won't copy just 1 file Pin
Justin Tay25-Aug-06 14:00
Justin Tay25-Aug-06 14:00 
GeneralRe: SHFileOperation is pissing me off - won't copy just 1 file Pin
AceCoolie26-Aug-06 4:47
AceCoolie26-Aug-06 4:47 

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.