forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

transfer windows screen to parameter array?

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
wsmith9920



Joined: 16 Sep 2013
Posts: 19

PostPosted: Wed Apr 13, 2016 10:58 pm    Post subject: transfer windows screen to parameter array? Reply with quote

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?
Back to top
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Sat Apr 23, 2016 5:02 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group