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