By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,300 Members | 2,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,300 IT Pros & Developers. It's quick & easy.

I need to adjust the size of a bitmap in a buffer

P: n/a
I am creating some image analysis software. My software is developed
specifically for bitmap images size 1280X1024 pixels. Now my boss wants
to be able to load images of any size into the software. I am looking
for a function that I can use when I load my image buffer that will
adjust the incoming image to the size I need (specifically 1280X1024).
I am using MS Visual Studio and MFC libraries. I don't know if I am
posting this in the correct place or not. I'm a VHDL and Verilog guy
and we don't have nearly the number of newsgroups as you programmer
guys (and gals). Please point me to the correct newsgroup if this post
doesn't belong here. Here is my code:

loadBuffer(int whichBuffer, TCHAR* importFileName)
{

BITMAPINFO bmp;
HANDLE hFile;
DWORD numBytesWrite;
DWORD pictBytes;
BITMAPFILEHEADER bmfInfo;

if( whichBuffer < 0 || whichBuffer >= numImageBuffers )
{
return false;
}

// Create the .BMP file.
hFile = CreateFileA((LPSTR)importFileName, GENERIC_READ,
(DWORD) 0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL);

if( hFile == INVALID_HANDLE_VALUE )
return false;

pictBytes=bitmapHeight*bytesPerPixel*bitmapWidth;//1024X3X1280

ReadFile(hFile, &bmfInfo, sizeof(BITMAPFILEHEADER),
&numBytesWrite, NULL);
if( sizeof(BITMAPFILEHEADER) == numBytesWrite )
{
ReadFile(hFile, &bmp.bmiHeader, sizeof(BITMAPINFOHEADER),
&numBytesWrite, NULL);
if( sizeof(BITMAPINFOHEADER) == numBytesWrite )
{

/* Here is where I need to stretch the image (I think) */
/* imageBuffer[whichBuffer] is 1024 X 3 X 1280 bytes */
/* I need to stretch or compress the image (importFileName) */
/* to fit in the imageBuffer[whichBuffer] */

ReadFile(hFile, imageBuffers[whichBuffer], pictBytes,
&numBytesWrite, NULL);
if( pictBytes == numBytesWrite )
{
CloseHandle(hFile);
return true;
}
}
}
CloseHandle(hFile);
return false;
}
Best Regards,
Derek

Aug 4 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

soxmax wrote:
I am creating some image analysis software. My software is developed
specifically for bitmap images size 1280X1024 pixels. Now my boss wants
to be able to load images of any size into the software. I am looking
for a function that I can use when I load my image buffer that will
adjust the incoming image to the size I need (specifically 1280X1024).
I am using MS Visual Studio and MFC libraries. I don't know if I am
posting this in the correct place or not. I'm a VHDL and Verilog guy
and we don't have nearly the number of newsgroups as you programmer
guys (and gals). Please point me to the correct newsgroup if this post
doesn't belong here. Here is my code:

loadBuffer(int whichBuffer, TCHAR* importFileName)
{

BITMAPINFO bmp;
HANDLE hFile;
DWORD numBytesWrite;
DWORD pictBytes;
BITMAPFILEHEADER bmfInfo;
[snip more MS-specific code]

You should probably ask on a Microsoft-specific group. See this FAQ for
a couple:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

Cheers! --M

Aug 4 '06 #2

P: n/a
>
You should probably ask on a Microsoft-specific group. See this FAQ for
a couple:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

Cheers! --M
Thanks.
Best Regards,
Derek

Aug 4 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.