plugins:viewer_plugins:loading_bitmap_images_the_bitmap_method

If your plugin specifies either the DVPFIF_CanReturnBitmap or DVPFIF_CanReturnThumbnail flags for an individual file in the call to one of the identification functions, then Directory Opus will call your exported DVP_LoadBitmap function to actually generate the bitmap image.

Additionally, if the file resides on an FTP site or within a ZIP file, and you specified the DVPFIF_CanHandleStreams plugin flag, Directory Opus will call your DVP_LoadBitmapStream function to generate the bitmap image from a data stream.

In both cases, Directory Opus will call your function with the name of the file to load (and the data stream pointer, if applicable), along with the VIEWERPLUGINFILEINFO structure that you returned from the DVP_IdentifyFile function. This allows your DVP_LoadBitmap function to access the information that you provided in the identification phase, which may make it easier for you to load the image. You can also use the dwPrivateData field of this structure to pass your own user-defined data between your identification and load functions.

Note that there may be some fields and flags in the VIEWERPLUGINFILEINFO structure that you are not able to set in the DVP_IdentifyFile function - if so, you should try to set them in the call to DVP_LoadBitmap instead.

As well as returning an HBITMAP from these functions, you also have the option to return a raw JPEG or PNG data stream. In this case, Opus will decode the image data itself. This lets you write a plugin that extracts JPEG or PNG image data from a given file format without having to have decoders for those image formats linked to your plugin.

To return a JPEG or PNG stream, you must allocate a block of memory using LocalAlloc(LMEM_FIXED) and copy the image data into it. You should then ensure that you have set either the DVPFIF_JPEGStream or DVPFIF_PNGStream flag in the VIEWERPLUGINFILEINFO structure. Finally, case the memory pointer to an HBITMAP and return it to Opus.