Have been trying to scale down a view to different scale but i'm having some troubles. The context is inside a video player (using VLCJ).
This code is being used to scale the image but after the first frame the image stops updating with next image for some reason.
public void newFrameRecieved(int[] rgbBuffer)
{
this.image.setRGB(0, 0, this.size.width, this.size.height, rgbBuffer, 0, this.size.width);
after = new BufferedImage(this.getWidth(), this.getHeight(), this.image.getType());
at = new AffineTransform();
scalingFactorX = (double)this.getWidth()/ (double)this.image.getWidth();
scalingFactorY = (double)this.getHeight()/ (double)this.image.getHeight();
at.scale(scalingFactorX, scalingFactorY);
scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
this.image = scaleOp.filter(this.image, after);
repaint();
}
If the middle part (all code between this.image.setRGB(......) and repaint();) is removed then it works(except the scaling part...)
Would really appreciate any help you guys can offer! The error recieved is the following:
JNA: Callback uk.co.caprica.vlcj.player.direct.DefaultDirectMediaPlayer$DisplayCallback@4516af24 threw the following exception:
java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
at sun.awt.image.IntegerInterleavedRaster.setDataElements(IntegerInterleavedRaster.java:301)
at java.awt.image.BufferedImage.setRGB(BufferedImage.java:1059)
at myVlcjWrapper.VideoSurfacePanel.newFrameRecieved(VideoSurfacePanel.java:65)
I understand the problem I'm just clueless as to how to fix it! Thanks!