Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Width Height problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 CJ   Members   -  Reputation: 122

Like
Likes
Like

Posted 31 October 1999 - 11:15 PM

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


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS