Device Independent Bitmaps

Starting a new thread for this, because the other one has veered from its original subject. The final post in that thread details a function in the external DLL I’m using to access the machine vision camera in my scanner. This function is supposed to take the data from the buffer and package it as a Device Independent Bitmap, for use in my application.

My code is as follows:

Declare the function that formats the DIB

Declare Function pxd_renderDIBCreate lib "XCLIBWNT.dll" (unitmap as Integer, framebuf as Integer, ulx as Integer, uly as Integer, lrx as Integer, lry as Integer, mode as Integer, options as Integer ) as Ptr

Create a memory block to contain the return from pxd_renderDIBCreate():

    dim capturedFrame as MemoryBlock = pxd_renderDIBCreate( 1, 1, 0, 0, -1, -1, 0, 0)

When I insert a break at this point, to check the contents of capturedFrame, I can see that there’s data there.

Put the image in an ImageWell:

    ImageWell1.Image = Picture.FromData(capturedFrame)

…only, I get nothing in the Image well. It just remains white.

So my questions are:

  1. Can I work with a DIB in RealBasic (2011R1.1)?
  2. Is an ImageWell the best way to do this, or is there a more efficient means of displaying it?


I think in my plugin code I have utility functions to convert between HDIB and HBITMAP on Windows.
And I have code to convert to Xojo pictures.
I could expose a few as part of the plugins if you need.

For display faster you often just have a canvas which paints the picture.

Hmm - so there’s no way to display the output of this function (as described in the documentation below) directly, without doing some kind of conversion first?

[code]An image frame buffer, or an area of interest within the image frame buffer, is copied to a newly created Windows Device Independent Bitmap (DIB) in global memory (e.g. using the Windows’ GlobalAlloc) and the handle to the DIB returned by pxd_renderDIBCreate. The bitmap created must be freed by pxd_renderDIBFree when no longer needed.


Color image frame buffers are copied as 24 bit RGB pixels without compression. Monochrome image frame buffers are copied as 8 bit pixels with a monochrome, identity, palette without compression.

There is, but the declares to convert are probably easier.

Do you mean using ImageMagick convert? Ultimately, I am planning to integrate that into my application for the file output side (creating DPX files, the industry standard for motion picture scanning) and hadn’t really considered using it here for the GUI frame display.

I’ve been thinking of using your plugins for this application, which ones would I need for this? the ImageMagick tools, or something else?



The plugin does not yet have a public command, as far as I know.

But if you write me email and say, you need a function taking HDIB and gives back Picture, I may be able to provide one in an updated plugin.

Does it work entirely in memory, or does it require that the file exist on disk first? I’m trying to avoid writing the file to disk (which I can already do as a 16bit TIFF direct from the DLL), because of performance concerns.

a HDIB is in memory, always.

Thanks, Christian - I sent you an email to your support@ address.