RE: Need a way to get an image of screen

new topic     » topic index » view thread      » older message » newer message

Thanks! I'll probably change my program to work directly with the memory 
to run faster.
Tommy Carlier wrote:
> 
> 
> > I Need a way to get an image of the screen.
> > It can be returned in Euphoria bitmap format or a sequence of colors(in 
> > seqence or atom form)
> > It needs to be fast, getPixel() is way too slow.
> > For example something like:
> > ret=getScreen(int startX, int startY,int endX,int endY)
> 
> If you need to do it in Windows, you could try my Shibby-library 
> ( download it from http://users.pandora.be/tommycarlier/eu/shibby.zip ). 
> 
> It allows you to manipulate 32-bit images in memory (should be fast as 
> hell). To use it, you must also have Win32Lib 0.55.0 or better (no 
> problem, i think).
> 
> ---> <code>
> 
> include shibby.ew
> 
> constant my_win = create(Window, "My Window", 0, Default, Default, 240, 
> 250, 0)
> Shibby_DIB my_dib
> my_dib = newDIB(width, height) -- create a Shibby-bitmap with the 
> specified width and height
> copyBlt( my_dib[SHB_DIB_HANDLE], 0, 0, my_win ) -- copies image of 
> my_win 
> to the bitmap
> copyBlt( my_dib[SHB_DIB_HANDLE], 0, 0, Screen ) -- copies image of 
> screen 
> to the bitmap
> 
> ---> </code>
> 
> To read the pixels, you can access the memory directly:
> start_address = my_dib[SHB_MEMORY]
> width = my_dib[SHB_WIDTH]
> pixel_address = start_address + ( y * width + x ) * 4 -- each pixel is 4 
> 
> bytes
> color = peek( {pixel_address, 4} ) -- color is now {blue, green, red, 
> alpha} -- each component is between 0 and 255
> color = {0, 0, 255, 0} -- no blue + no green + full red = red
> poke( pixel_address, color )
> 
> To display the image back on the window/pixmap/screen:
> DrawBitmap( my_win, my_dib[SHB_DIB_HANDLE], 0, 0 ) -- draw bitmap on 
> window my_win at position (0, 0)
> 
> I hope this helps.
> 
> --
> 
> Tommy Carlier
> tommy online: http://users.pandora.be/tommycarlier
>

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu