Code: Select all
// This function adjusts the brightness (delta = [-255, 255])
bool CPicture::Adjust_Brightness(int16 i16Delta)
{
bool bResult = false;
try
{
CHECK_MEM_LEAKS;
// Do we have a valid delta?
if(i16Delta >= -255 && i16Delta != 0 && i16Delta <= 255)
{
GFL_BITMAP *pgflOrg;
GFL_ERROR gflError;
// Convert the DDB to a bitmap
if((gflError = gflConvertDDBIntoBitmap(m_hBmPic, &pgflOrg)) == GFL_NO_ERROR)
{
GFL_BITMAP *pgflNew;
// Adjust the brightness
if((gflError = gflBrightness(pgflOrg, &pgflNew, i16Delta)) == GFL_NO_ERROR)
{
// Free the current picture
if(m_hBmPic)
{
// Free the picture
DeleteObject(m_hBmPic);
m_hBmPic = NULL;
}
// Copy the picture
if((gflError = gflConvertBitmapIntoDDB(pgflNew, &m_hBmPic)) == GFL_NO_ERROR)
{
// Set the size of the picture
m_szSize.cx = pgflNew->Width;
m_szSize.cy = pgflNew->Height;
// We have a valid picture
bResult = true;
}
// Free the resources
gflFreeBitmap(pgflNew);
}
// Free the resources
gflFreeBitmap(pgflOrg);
}
}
else if(!i16Delta)
bResult = true;
}
catch(...) { OnException(__FILE__, __LINE__, __FUNCSIG__, __TIMESTAMP__); }
return bResult;
}
Code: Select all
gflFreeBitmap(pgflNew);
Code: Select all
First-chance exception at 0x7c96df51 (ntdll.dll) in Dms.exe: 0xC0000005: Access violation reading location 0xbaadf005.
PS
If I replace the gflBrightness call with a gflAdjustHLS call, the error doesn't occur. So, it definitely seems to be a bug with the gflBrightness routine.