wsmith9920
Joined: 16 Sep 2013 Posts: 19
|
Posted: Wed Apr 13, 2016 10:58 pm Post subject: transfer windows screen to parameter array? |
|
|
I'd like to transfer the windows screen into the 3-index RGB array commonly called "parray". I can do this via disk I/O as follows:
1) get handle to windows screen using win32api functions
2) read screen in using bitblt
3) using a handle, export to a .BMP file using export_bmp@
4) read the file into parray using get_dib_block@
Is there a way to bypass the disk I/O, in other words, after bitblt, to transfer the screen data directly into parray? |
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Sat Apr 23, 2016 5:02 am Post subject: |
|
|
It's perhaps easier than you might imagine. You'll need to have a 3 dimension array. One dimension of size 3 for the R, G, and B values, and addressed in (X,Y) with the other two dimensions. These X and Y correspond to the X and Y of your image.
The put_dib call allows you to specify the array size that you are using AND the array portion that you have filled. You can get BMP or JPG as a result.
In my code, I use the following declaration:
Code: |
character dib_array(3,0:max_across_horizontal,0:max_down_horizontal)
|
where the horizontal indicates that the direction of the "Y" axis.
So, the X direction is down and the Y direction is across.
The first dimension of size 3 indicates that index=1 for R, 2=G, 3=B.
Get each pixel at the row and column address and store the RGB values as indicated.
Then output using something like:
Code: |
call put_dib_block@(trim(graphicfilename),dib_array,
$ max_across_horizontal+1,max_down_horizontal+1,
$ dib_adx,dib_ady,max_plot_y,max_plot_x,0L,0L,err)
|
dib_adx and dib_ady are set to zero as initial values. The 0L are used because my code is compiled with 16 bit integers as standard (I*2 not i*4).
If the filename ends in BMP, then it's BMP, if .JPG, the JPG.
About as easy as it can get. |
|