58 views
in Embedded Wizard Studio by
Hi,

 

Is it possibile to read the framebuffer during prototyping (like using Intrinsics Modules)?
 

I asked the same question for WebGL, it works, but I want to make it work on the prototype too.
https://ask.embedded-wizard.de/10303/how-to-access-the-framebuffer-on-webgl

 

Kind Regards,

John

1 Answer

0 votes
by

Hello John,

from technical point of view, it could be possible. It is however a difficult task. I will try to give you some hints:

1. You will need to implement the access operation inside an Intrinsic Module. The code inside the Intrinsic Module is C and you can implement there mostly whatever you would like to perform at the runtime in the target system. In your case you would implement a function to access the pixel information of a bitmap. The function could look like the following:

XColor GetPixelColorForBitmap( XBitmap* aBitmap, XPoint aPosition )
{
  * Lock the bitmap aBitmap.
  * Access the pixel at position aPosition inside the locked bitmap memory.
  * Unlock the bitmap again
  * Evtl. convert/recalculate the acceessed pixel data to get a color value
  * Return the color value of the accessed pixel
}

When implementing an Intrinsic Module you have to note that during prototyping the involved target system is Windows and not WebGL even if you have configured the profile for WebGL. Therefore the implementation of the above function uses the API valid for the windows target system. In particular the function to lock and unlock the bitmap as well as data structures representing the locked bitmap. This depends on  the color format of the locked bitmap. In most cases, during prototyping the color format will be RGBA8888. See also Platform Package reference: Type XBitmapLock.

2. In your Embedded Wizard project you will need to invoke the Intrinsic Module function and provide the correct frame buffer. The problem here is the access to the frame buffer. From technical point of view the 'real' framebuffer is part of Windows and not accessible. What is accessible is an off-screen buffer used during screen update. You can access this buffer during screen update only. I would recommend to override for this purpose in the Application component the method DrawForeground(). This method is invoked at the end of the screen update and it receives in its first parameter the mentioned off-screen bitmap, here called as canvas. Using this canvas you could now invoke the Intrinsic function to query the pixel data. For example:

From technical point of view, the above code could also be implemented in any other Draw(), DrawBackground() or DrawForeground() method. For example, if you have a GUI component where you want to display a rectangle with color corresponding to some background pixel, you could override in this component the method DrawBackground() and implement there the pixel color query operation. Then you could store the value for the next screen update, .. etc.

Restriction: You can only query the color of one pixel. The Intrinsic Modules don't allow transfer of arrays.

I hope it helps you further.

Best regards

Paul Banach

by
Hi Paul,

Thank you very much, it's clear. I will have a try.

Regards,
John

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...