Merge pull request #25322 from sepperliu:patch-1

Update highgui+HighGui.java
This commit is contained in:
Alexander Smorkalov 2024-04-04 10:23:24 +03:00 committed by GitHub
commit bf7208e1ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -62,14 +62,9 @@ public final class HighGui {
if (m.channels() > 1) {
type = BufferedImage.TYPE_3BYTE_BGR;
}
int bufferSize = m.channels() * m.cols() * m.rows();
byte[] b = new byte[bufferSize];
m.get(0, 0, b); // get all the pixels
BufferedImage image = new BufferedImage(m.cols(), m.rows(), type);
final byte[] targetPixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData();
System.arraycopy(b, 0, targetPixels, 0, b.length);
m.get(0, 0, targetPixels);
return image;
}