04-27-2010 11:28 AM
I am trying to capture the screen image from an Agilent oscilloscope as a bitmap. Agilent provides a method for capturing the screen bitmap as a byte array (ViChar[]).
ViStatus Ag546XX_SystemGetScreenBitmap( ViSession Vi, ViInt32 pBitmapBufferSize, ViChar[] pBitmap, ViInt32* pBitmapActualSize);
I can fwrite the ViChar[] pBitmap array directly to a bitmap file and get a readable bitmap, so pBitmap is a full bitmap file with header information. I can then display the bitmap to a CVI control using GetBitmapFromFile(). I'd like to remove the step of saving pBitmap to a file and instead display the image directly from pBitmap.
Is there any way to assign a bitmapID to pBitmap? I can create a new bitmapID using NewBitmap(), but that requires me to extract the bit depth, dimension information and data fields from pBitmap. Furthermore, the data in pBitmap is "flipped" vertically (because of the bitmap standard). NewBitmap() then tries to flip the data again, so my final image is inverted.
So as it stands, I have two options: save to and read from an external file (inelegant), or write a function to parse through the bitmap information and invert the data (cumbersome). Does anybody know if there is a simple way to assign a bitmapID to my perfectly good bitmap data?
04-28-2010 02:35 AM
I'm afraid there isn't an easy way to do what you are asking. First of all keep in mind that NewBitmap (), regardless of the option you set to the command, always creates a bitmap that matches the graphic options of the system the command is runnin into. That is: if you are using a 24-bit color depth, very common nowadays, CreateBitmap will create a bitmap with such colour depth even if you ask for a monochrome bitmap! If your instrument returns a monochrome or grayscale bitmap or even a color bitmap but with different colour depth some arrangement will be needed not alway as per the pixel order but for color informations as well.
Given this, the "inelegant" road that passes by writing and reading from disk is an easy way to let the system perform all necessary adaptations to the bitmap informations.
If you don't want to go this way you can operate on bitmap informations and create your own bitmap in memory: in this contribution I made some time ago you can find some links and routines to treat bitmap. The contribution was aimed to another target (converting colour depth), but some of the functions in it may be of some help to you.
04-28-2010 08:45 AM
Thanks, I didn't realize there was an issue with color depth. I guess that is another reason to keep doing it the way I'm way I am.
I took a look at your color-to-mono converter and the code seems a little involved. That's what I was trying to avoid. I appreciate the information, though. Now I know!
04-29-2010 11:27 AM