mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-30 22:12:55 +01:00
Fossil Hybrid HR: Fix washed out colors in imported watchfaces
Fixes #2995
This commit is contained in:
parent
82b3e0d963
commit
afeeff5293
@ -102,6 +102,22 @@ public class ImageConverter {
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static @ColorInt int convertFromMonochrome(int color) {
|
||||||
|
int result = 0;
|
||||||
|
switch (color) {
|
||||||
|
case 1:
|
||||||
|
result = 0xff * 1/3;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
result = 0xff * 2/3;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
result = 0xff;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return Color.rgb(result, result, result);
|
||||||
|
}
|
||||||
|
|
||||||
public static Bitmap decodeFromRLEImage(byte[] rleImage) {
|
public static Bitmap decodeFromRLEImage(byte[] rleImage) {
|
||||||
ByteBuffer buf = ByteBuffer.wrap(rleImage);
|
ByteBuffer buf = ByteBuffer.wrap(rleImage);
|
||||||
buf.order(ByteOrder.LITTLE_ENDIAN);
|
buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
@ -113,10 +129,9 @@ public class ImageConverter {
|
|||||||
while (buf.remaining() > 2) {
|
while (buf.remaining() > 2) {
|
||||||
int repetitions = buf.get() & 0xff;
|
int repetitions = buf.get() & 0xff;
|
||||||
int pixel = buf.get() & 0xff;
|
int pixel = buf.get() & 0xff;
|
||||||
int color = pixel << 6;
|
int color = convertFromMonochrome(pixel & 0b00000011);
|
||||||
int combinedColor = Color.rgb(color, color, color);
|
|
||||||
for (int i=0; i<repetitions; i++) {
|
for (int i=0; i<repetitions; i++) {
|
||||||
bitmap.setPixel(posX, posY, combinedColor);
|
bitmap.setPixel(posX, posY, color);
|
||||||
posX++;
|
posX++;
|
||||||
if (posX >= width) {
|
if (posX >= width) {
|
||||||
posX = 0;
|
posX = 0;
|
||||||
@ -139,11 +154,10 @@ public class ImageConverter {
|
|||||||
int posX = 239;
|
int posX = 239;
|
||||||
int posY = 239;
|
int posY = 239;
|
||||||
while (buf.remaining() > 0) {
|
while (buf.remaining() > 0) {
|
||||||
int currentPixels = buf.get() & 0xff;
|
int currentPixel = buf.get() & 0xff;
|
||||||
for (int shift=6; shift>=0; shift-=2) {
|
for (int shift=6; shift>=0; shift-=2) {
|
||||||
int color = ((currentPixels >> shift) & 0b00000011) << 6;
|
int color = convertFromMonochrome((currentPixel >> shift) & 0b00000011);
|
||||||
int combinedColor = Color.rgb(color, color, color);
|
bitmap.setPixel(posX, posY, color);
|
||||||
bitmap.setPixel(posX, posY, combinedColor);
|
|
||||||
posX--;
|
posX--;
|
||||||
if (posX < 0) {
|
if (posX < 0) {
|
||||||
posX = 239;
|
posX = 239;
|
||||||
|
Loading…
Reference in New Issue
Block a user