#86 Create image from user bits without copy of pixel data

None
closed
None
5
2015-03-15
2014-02-12
No

The package contains patches enabling creation of FIBITMAP from user bits without copying the data.

Except the files provided you need to add:

Utilities.h:

DLL_API FIBITMAP * DLL_CALLCONV FreeImage_AllocateHeaderForBits(BYTE* bits, unsigned pitch, FREE_IMAGE_TYPE type, int width, int height, int bpp FI_DEFAULT(8), unsigned red_mask FI_DEFAULT(0), unsigned green_mask FI_DEFAULT(0), unsigned blue_mask FI_DEFAULT(0));

FreeImage.h

DLL_API FIBITMAP *DLL_CALLCONV FreeImage_ConvertFromRawBitsEx(BOOL copySource, BYTE *bits, FREE_IMAGE_TYPE, int width, int height, int pitch, unsigned bpp, unsigned red_mask, unsigned green_mask, unsigned blue_mask, BOOL topdown FI_DEFAULT(FALSE));

One will use FreeImage_ConvertFromRawBitsEx to create a new FIBITMAP*, passing false for the first argument, avoiding creation of private storage for the pixels.
One must use FreeImage_Unload as unusual to release the header and metadata!

Included are two test cases. One for OpenCV and one for Qt's QImage. In both cases the image is loaded and saved by FreeImage, but processed by the other frameworks without any unnecessary copies.

1 Attachments

Discussion

  • Mihail Naydenov

    Mihail Naydenov - 2014-02-13

    Here is a different usage - define a "view" of a subsection of an existing dib.

     
  • Hervé Drolon

    Hervé Drolon - 2014-04-05
    • status: open --> accepted
    • assigned_to: Hervé Drolon
    • Group: -->
     
  • Hervé Drolon

    Hervé Drolon - 2014-04-05

    Hi Mihail,

    Many thanks for this very good addition to the library !
    Your patch in now merged with the CVS.
    I will update the doc using your (very useful) sample use-cases.

    Hervé

     
  • Hervé Drolon

    Hervé Drolon - 2015-03-15

    fixed in release 3.17.0

     
  • Hervé Drolon

    Hervé Drolon - 2015-03-15
    • status: accepted --> closed
     

Anonymous
Anonymous

Cancel  Add attachments