Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

Grab region of screen

Hi im not really sure how to explain this problem but i want to be able to grab pixels from a rectangle region on a screen at position x1,y1 and x2,y2 and copy those exact pixels onto a form... hard to explain I think


Here is a basic image example

It would look like that..where the red rectanagle region is copied into the form as the image shows.. does anyone know how I could do this?

i.imgur com/iP8iIwp.jpg

(can't post links....)

If anyone can post the image here for me that would be nice thanks
You can get a picture of the entire desktop then only get the select area and save that image. Cant code atm so this is the only bit I can help.
Check out the class "Robot" in the "java.awt" package. Can do exactly what you want. Click.
Hey I have a signature.
(Feb 20, 2016 08:08 PM)Sogomn Wrote:  Check out the class "Robot" in the "java.awt" package. Can do exactly what you want.

Thanks I solved that problem...but now I need to make the bufferedimage transparent
(Feb 22, 2016 06:39 PM)quartzd Wrote:  Thanks I solved that problem...but now I need to make the bufferedimage transparent

But your screen is not transparent. What do you mean exactly? Do you want to add an alpha channel? Simply convert it.

Code
public static BufferedImage convert(final BufferedImage image, final int type) {
   final int width = image.getWidth();
   final int height = image.getHeight();
   final BufferedImage newImage = new BufferedImage(width, height, type);
   final Graphics2D g = newImage.createGraphics();

   g.drawImage(image, 0, 0, null);
   g.dispose();

   return newImage;
}

Then call it like this:

Code
final BufferedImage alphaImage = convert(screenImage, BufferedImage.TYPE_INT_ARGB);
Hey I have a signature.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by quartzdFeb 20, 2016 03:38 PM 6 201 Feb 20, 2016 03:38 PM
Last Post: quartzd
[.NET] by Only3Mar 12, 2015 11:10 AM 0 312 Mar 12, 2015 11:10 AM
Last Post: Only3
[.NET] by AEDEADNov 30, 2014 02:26 PM 12 647 Nov 30, 2014 02:26 PM
Last Post: Dredd