Giter VIP home page Giter VIP logo

Comments (2)

eomernick avatar eomernick commented on September 17, 2024

Looking at the FreeImage documentation it looks like you need to call the FreeImage_Unload function to avoid leaks.

Maybe something like this:

  FIBITMAP* ReOrient(FIBITMAP *bitmap) {
      FITAG *tagValue = NULL;
      FIBITMAP *newBitmap;  
      FreeImage_GetMetadata(FIMD_EXIF_MAIN, bitmap, "Orientation", &tagValue);
      switch (tagValue == NULL ? 0 : *((short *) FreeImage_GetTagValue(tagValue))) {
        case 6:
          newBitmap = FreeImage_RotateClassic(bitmap, 270);
          break;
        case 3:
          newBitmap = FreeImage_RotateClassic(bitmap, 180);
          break;
        case 8:
          newBitmap = FreeImage_RotateClassic(bitmap, 90);
          break;
        default:
          newBitmap = FreeImage_Clone(bitmap);
         break;
      }
    FreeImage_Unload(bitmap);
    return newBitmap;
  }

The Documentation can be found here: http://iweb.dl.sourceforge.net/project/freeimage/Source%20Documentation/3.15.4/FreeImage3154.pdf

Page 12 of the document has the unload method (page 16 of the pdf).

EDIT: I just tested this code using the original script and it seems to work without leaking memory.

from image_science.

Blargel avatar Blargel commented on September 17, 2024

I sent a pull request after testing this with eomernick. See #17

from image_science.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.