0
H ow我可以將給定的Pixmap
轉換爲字節數組嗎?從像素讀取字節 - libGDX
byte[] bytes = Gdx.files.internal("image.png").readBytes();
// pass the correct bytes into pixmap
Pixmap pixmap = new Pixmap(bytes, 0, bytes.length);
byte[] sameBytes = new byte[SIZE];
int count = 0;
for (int x = 0; x < pixmap.getWidth(); x++) {
for (int y = 0; y < pixmap.getHeight(); y++) {
int pixel = pixmap.getPixel(x, y);
sameBytes[count++] = ((pixel >> 24) & 0xff);
sameBytes[count++] = ((pixel >> 16) & 0xff);
sameBytes[count++] = ((pixel >> 8) & 0xff);
sameBytes[count++] = ((pixel ) & 0xff);
}
}
// sameBytes is not correct bytes into pixmap
Pixmap pixmap = new Pixmap(sameBytes, 0, sameBytes.length);
無法從圖像數據加載像素圖
檢查[這](https://stackoverflow.com/questions/34482186/ extract-byte-from-libgdx-texture)主題 – Squiddie
@Squiddie這些代碼行的問題,它不能在HTML項目上運行。 – Crowni
我有原始數據沒有編碼數據這是我的主要問題。 – Crowni