import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.io.File;
import java.time.Duration;
import java.time.Instant;
import javax.imageio.ImageIO;
class Ideone
{
public static byte IntToByte(int Val)
{
if (Val > 127)
{
Val = Val - 256;
}
return (byte)Val;
}
{
int BmpW = 30 * 256;
int BmpH = 20 * 256;
Instant SW = Instant.now();
byte[] TestBmp__
= ((DataBufferByte)TestBmp.
getRaster().
getDataBuffer()).
getData(); int TestBmp__Stride = BmpW * 3;
int Ptr = 0;
for (int YY = 0; YY < 10; YY++)
{
for (int XX = 0; XX < 10; XX++)
{
int PtrOffset = (TestBmp__Stride * 512 * YY) + (768 * 3 * XX);
Ptr = PtrOffset;
for (int Y = 0; Y < 256; Y++)
{
for (int X = 0; X < 256; X++)
{
TestBmp__[Ptr + 0] = IntToByte(0);
TestBmp__[Ptr + 1] = IntToByte(Y);
TestBmp__[Ptr + 2] = IntToByte(X);
Ptr += 3;
}
Ptr = Ptr + TestBmp__Stride - (3 * 256);
}
Ptr = PtrOffset + (3 * 256);
for (int Y = 0; Y < 256; Y++)
{
for (int X = 0; X < 256; X++)
{
TestBmp__[Ptr + 0] = IntToByte(Y);
TestBmp__[Ptr + 1] = IntToByte(X);
TestBmp__[Ptr + 2] = IntToByte(0);
Ptr += 3;
}
Ptr = Ptr + TestBmp__Stride - (3 * 256);
}
Ptr = PtrOffset + (3 * 512);
for (int Y = 0; Y < 256; Y++)
{
for (int X = 0; X < 256; X++)
{
TestBmp__[Ptr + 0] = IntToByte(X);
TestBmp__[Ptr + 1] = IntToByte(0);
TestBmp__[Ptr + 2] = IntToByte(Y);
Ptr += 3;
}
Ptr = Ptr + TestBmp__Stride - (3 * 256);
}
Ptr = PtrOffset + (TestBmp__Stride * 256);
for (int Y = 0; Y < 256; Y++)
{
for (int X = 0; X < 256; X++)
{
TestBmp__[Ptr + 0] = IntToByte(255);
TestBmp__[Ptr + 1] = IntToByte(Y);
TestBmp__[Ptr + 2] = IntToByte(X);
Ptr += 3;
}
Ptr = Ptr + TestBmp__Stride - (3 * 256);
}
Ptr = PtrOffset + (TestBmp__Stride * 256) + (3 * 256);
for (int Y = 0; Y < 256; Y++)
{
for (int X = 0; X < 256; X++)
{
TestBmp__[Ptr + 0] = IntToByte(Y);
TestBmp__[Ptr + 1] = IntToByte(X);
TestBmp__[Ptr + 2] = IntToByte(255);
Ptr += 3;
}
Ptr = Ptr + TestBmp__Stride - (3 * 256);
}
Ptr = PtrOffset + (TestBmp__Stride * 256) + (3 * 512);
for (int Y = 0; Y < 256; Y++)
{
for (int X = 0; X < 256; X++)
{
TestBmp__[Ptr + 0] = IntToByte(X);
TestBmp__[Ptr + 1] = IntToByte(255);
TestBmp__[Ptr + 2] = IntToByte(Y);
Ptr += 3;
}
Ptr = Ptr + TestBmp__Stride - (3 * 256);
}
}
}
System.
out.
println(Duration.
between(SW, Instant.
now()).
toMillis());
try
{
ImageIO.
write(TestBmp,
"png",
new File("/home/xxx/TestJava.png")); }
{
}
}
}