Skip to content

Commit a757c7b

Browse files
vladimirsamsonovtonsky
authored andcommitted
ColorType map fix
Signed-off-by: vladimir.samsonov <vladimir.samsonov@devexpress.com>
1 parent 30602e9 commit a757c7b

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

shared/java/ColorType.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ public enum ColorType {
6868
*/
6969
BGR_101010X_XR,
7070

71+
/**
72+
* Pixel with 10 used bits (most significant) followed by 6 unused bits for red, green, blue, alpha; in 64-bit word
73+
*/
74+
RGBA_10x6,
75+
7176
/**
7277
* Pixel with grayscale level in 8-bit byte
7378
*/
@@ -149,6 +154,8 @@ public int getBytesPerPixel() {
149154
case RGB_101010X: return 4;
150155
case BGRA_1010102: return 4;
151156
case BGR_101010X: return 4;
157+
case BGR_101010X_XR: return 4;
158+
case RGBA_10x6: return 8;
152159
case GRAY_8: return 1;
153160
case RGBA_F16NORM: return 8;
154161
case RGBA_F16: return 8;
@@ -176,6 +183,8 @@ public int getShiftPerPixel() {
176183
case RGB_101010X: return 2;
177184
case BGRA_1010102: return 2;
178185
case BGR_101010X: return 2;
186+
case BGR_101010X_XR: return 2;
187+
case RGBA_10x6: return 3;
179188
case GRAY_8: return 0;
180189
case RGBA_F16NORM: return 3;
181190
case RGBA_F16: return 3;
@@ -230,6 +239,7 @@ public ColorAlphaType validateAlphaType(ColorAlphaType alphaType) {
230239
case RGBA_F16NORM:
231240
case RGBA_F16:
232241
case RGBA_F32:
242+
case RGBA_10x6:
233243
case R16G16B16A16_UNORM:
234244
if (ColorAlphaType.UNKNOWN == alphaType)
235245
return null;
@@ -242,6 +252,7 @@ public ColorAlphaType validateAlphaType(ColorAlphaType alphaType) {
242252
case RGB_888X:
243253
case RGB_101010X:
244254
case BGR_101010X:
255+
case BGR_101010X_XR:
245256
alphaType = ColorAlphaType.OPAQUE;
246257
break;
247258
}

tests/java/BitmapTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static io.github.humbleui.skija.test.runner.TestRunner.*;
44

5+
import io.github.humbleui.skija.ColorType;
56
import io.github.humbleui.skija.Bitmap;
67
import io.github.humbleui.skija.Canvas;
78
import io.github.humbleui.skija.ColorAlphaType;
@@ -14,6 +15,7 @@ public void execute() throws Exception {
1415
TestRunner.testMethod(this, "base");
1516
TestRunner.testMethod(this, "swap");
1617
TestRunner.testMethod(this, "getSurfaceNull");
18+
TestRunner.testMethod(this, "colorTypeMapTest");
1719
}
1820

1921
public void base() throws Exception {
@@ -75,4 +77,17 @@ public void getSurfaceNull() throws Exception {
7577
canvas.close();
7678
}
7779
}
80+
81+
public void colorTypeMapTest() throws Exception {
82+
for (ColorType ct : ColorType.values()) {
83+
try (Bitmap bitmap = new Bitmap(); Bitmap dst = new Bitmap()) {
84+
bitmap.allocN32Pixels(5, 5);
85+
var info = bitmap.getImageInfo().withColorType(ct);
86+
boolean ok = dst.allocPixels(info);
87+
assertEquals(true, ok);
88+
assertEquals(ct, dst.getImageInfo().getColorType());
89+
assertEquals((long)(ct.getBytesPerPixel() * 5), dst.getRowBytes());
90+
}
91+
}
92+
}
7893
}

0 commit comments

Comments
 (0)