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

S

soxmax

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
 
M

mlimber

soxmax said:
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-lite/how-to-post.html#faq-5.9

Cheers! --M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top