Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

CJ

Width Height problem

This topic is 6904 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When i use the following MFC SDI code:

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

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!