code:if (ar.IsStoring()) { // TODO: add storing code here // This code is for 24 Bit Bitmaps only. int i,j,k; // These are the loop variables ar << bmfh.bfType; //bmfh: Bit Map file Header ar << bmfh.bfSize; ar << bmfh.bfReserved1; ar << bmfh.bfReserved2; ar << bmfh.bfOffBits; ar << bmi.bmiHeader.biSize; //bmi: Bit Map Info ar< ar << bmi.bmiHeader.biHeight; ar << bmi.bmiHeader.biPlanes; ar << bmi.bmiHeader.biBitCount; ar << bmi.bmiHeader.biCompression; ar << bmi.bmiHeader.biSizeImage; ar << bmi.bmiHeader.biXPelsPerMeter; ar << bmi.bmiHeader.biYPelsPerMeter; ar << bmi.bmiHeader.biClrUsed; ar << bmi.bmiHeader.biClrImportant; //there is no colour table for 24 bit bitmaps long int cnt = 0; // counter for(i = 0; i < bmi.bmiHeader.biHeight; i++) { for(j = 0;j < bmi.bmiHeader.biWidth;j++) { for ( k = 1; k < 4; k++) { ar << bits[cnt]; cnt++; } } for (j = 0;j < bmi.bmiHeader.biWidth % 4;j++) { ar << bits[cnt]; cnt++; //image has a double word boundary. } } } else { // TODO: add loading code here int i, j, k; ar >> bmfh.bfType; //bmfh:BitMap File Header ar >> bmfh.bfSize ; ar >> bmfh.bfReserved1; ar>>bmfh.bfReserved2; ar>>bmfh.bfOffBits; ar>>bmi.bmiHeader.biSize; //bmi: Bit Map Info ar>>bmi.bmiHeader.biWidth; ar>>bmi.bmiHeader.biHeight; ar>>bmi.bmiHeader.biPlanes; ar>>bmi.bmiHeader.biBitCount; ar>>bmi.bmiHeader.biCompression; ar>>bmi.bmiHeader.biSizeImage; ar>>bmi.bmiHeader.biXPelsPerMeter; ar>>bmi.bmiHeader.biYPelsPerMeter; ar>>bmi.bmiHeader.biClrUsed; ar>>bmi.bmiHeader.biClrImportant; if (bmi.bmiHeader.biBitCount==24) { // 24 bit bitmap =============================== bits=(unsigned char *) malloc (((long int)((bmi.bmiHeader.biWidth * 3 + bmi.bmiHeader.biWidth % 4) * bmi.bmiHeader.biHeight)) * sizeof(unsigned char)); long int cnt = 0; for(i = 0;i < bmi.bmiHeader.biHeight;i++) { for(j = 0;j < bmi.bmiHeader.biWidth;j++) { for (k = 1;k < 4;k++) { ar >> bits[cnt]; cnt++; } } for (j = 0;j < bmi.bmiHeader.biWidth % 4; j++) { ar>>bits[cnt]; cnt++; } } } else MessageBox(NULL,"Sorry, this is not a 24 Bit Bitmap.", "File Open Error",MB_ICONSTOP|MB_OK); }
and I ask in the View for it's width and height like:
code:CSOMETHINGDoc *pDoc;CSize sizeTotal;sizeTotal.cx = pDoc->bmi.bmiHeader.biWidth;sizeTotal.cy = pDoc->bmi.bmiHeader.biHeight;
It doesn't give me the right values, see....when I've got a 640 x 480 bitmap, it says 0 width and 1180 height.
Does anyone of you know what the problem is?
I use the values to initialize my scrollbars..........but this way, it's not going well. pleaaaaaase help.
------------------
Dance with me......