Silverfrost Forums

Welcome to our forums

transfer windows screen to parameter array?

13 Apr 2016 9:58 #17415

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?

23 Apr 2016 4:02 #17442

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:

	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:

	  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 (I2 not i4).

If the filename ends in BMP, then it's BMP, if .JPG, the JPG.

About as easy as it can get.

Please login to reply.