[BUG] Access Violation when using gflBrightness

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: helmut, XnTriq, xnview

iycgtptyarvg
Posts: 81
Joined: Wed Jan 24, 2007 3:59 pm
Location: The Netherlands

[BUG] Access Violation when using gflBrightness

Post by iycgtptyarvg »

The following routine to change the brightness of a picture worked with v2.54, but gives me an error with v2.67.

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;
}
The error occurs on the line:

Code: Select all

gflFreeBitmap(pgflNew);
The error is:

Code: Select all

First-chance exception at 0x7c96df51 (ntdll.dll) in Dms.exe: 0xC0000005: Access violation reading location 0xbaadf005.
Is this a newly introduced bug?

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.
User avatar
xnview
Author of XnView
Posts: 38338
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: [BUG] Access Violation when using gflBrightness

Post by xnview »

iycgtptyarvg wrote:The following routine to change the brightness of a picture worked with v2.54, but gives me an error with v2.67.
Could you send me a PM with your email, i would like to send you a test dll
Pierre.
iycgtptyarvg
Posts: 81
Joined: Wed Jan 24, 2007 3:59 pm
Location: The Netherlands

Re: [BUG] Access Violation when using gflBrightness

Post by iycgtptyarvg »

xnview wrote:
iycgtptyarvg wrote:The following routine to change the brightness of a picture worked with v2.54, but gives me an error with v2.67.
Could you send me a PM with your email, i would like to send you a test dll
I sent you a PM a couple of days ago, but didn't receive anything. Did you find the problem?
User avatar
xnview
Author of XnView
Posts: 38338
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: [BUG] Access Violation when using gflBrightness

Post by xnview »

iycgtptyarvg wrote:
xnview wrote:
iycgtptyarvg wrote:The following routine to change the brightness of a picture worked with v2.54, but gives me an error with v2.67.
Could you send me a PM with your email, i would like to send you a test dll
I sent you a PM a couple of days ago, but didn't receive anything. Did you find the problem?
Will be fixed in next release...
Pierre.