Copy a specific part of the buffer image to another buffer image

I have one big buffer image.

I want to create another buffer image with data from the first

I tried to do rasterwithbuffer.getData(new Rectangle(x,y,width,height))

And then buffer2.setData(raster)

But due to the reason, the data is transferred x, y instead of 0.0. For example, if I have a pixel in x, y in the original, I will still have it in x, y in the new instead of 0.0, because x, y is where the rectangle is translated.

So, is there a way to correctly convert a bitmap OR is there a better solution for copying an image?

Edit: I also managed to do this with getGraphics().drawImage(). There is a method for determining 2 rectangles by determining their angles. But the method below is better because it does not overload.

Edit2: It looks like the subimag is connected to the original, is there any other way to create a spooled file with data and section sizes that are really original?

+5
source share
1 answer

Java image should work for you. try;

imageTwo = imageOne.getSubimage(x, y, width, height);

Hope this helps :-)

+12
source

All Articles