Skip to content

Commit d26c6d2

Browse files
committed
fix: rgb666的排序方式
1 parent 693a3fd commit d26c6d2

File tree

6 files changed

+92
-43
lines changed

6 files changed

+92
-43
lines changed

Image2Display/Image2Display/Assets/Languages/en-US.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
<system:String x:Key="RGB555High">16-bit Color, RGB555 High Fill</system:String>
112112
<system:String x:Key="RGB666">18-bit Color, RGB666</system:String>
113113
<system:String x:Key="RGB666High">18-bit Color, RGB666 High Fill</system:String>
114+
<system:String x:Key="RGB666Low">18-bit Color, RGB666 Low Fill</system:String>
114115
<system:String x:Key="RGB888">24-bit Color, RGB888</system:String>
115116
<system:String x:Key="ARGB8888">32-bit Color, ARGB8888</system:String>
116117
<system:String x:Key="RGBA8888">32-bit Color, RGBA8888</system:String>

Image2Display/Image2Display/Assets/Languages/zh-CN.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
<system:String x:Key="RGB555High">16位色,RGB555高位填充</system:String>
115115
<system:String x:Key="RGB666">18位色,RGB666</system:String>
116116
<system:String x:Key="RGB666High">18位色,RGB666高位填充</system:String>
117+
<system:String x:Key="RGB666Low">18位色,RGB666低位填充</system:String>
117118
<system:String x:Key="RGB888">24位色,RGB888</system:String>
118119
<system:String x:Key="ARGB8888">32位色,ARGB8888</system:String>
119120
<system:String x:Key="RGBA8888">32位色,RGBA8888</system:String>

Image2Display/Image2Display/Helpers/ByteOrder.cs

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,36 @@ public static SolidColorBrush[] GetOrderColors(int colorMode, int fullColor, int
9494
4 => byteOrder switch
9595
{
9696
0 => [
97-
EC,EC,EC,EC, EC,EC,RC,RC,
98-
RC,RC,RC,RC, GC,GC,GC,GC,
99-
GC,GC,BC,BC, BC,BC,BC,BC,
97+
EC,EC,RC,RC, RC,RC,RC,RC,
98+
EC,EC,GC,GC, GC,GC,GC,GC,
99+
EC,EC,BC,BC, BC,BC,BC,BC,
100100
TC,TC,TC,TC, TC,TC,TC,TC,
101101
],
102102
1 => [
103-
GC,GC,BC,BC, BC,BC,BC,BC,
104-
RC,RC,RC,RC, GC,GC,GC,GC,
105-
EC,EC,EC,EC, EC,EC,RC,RC,
103+
EC,EC,BC,BC, BC,BC,BC,BC,
104+
EC,EC,GC,GC, GC,GC,GC,GC,
105+
EC,EC,RC,RC, RC,RC,RC,RC,
106106
TC,TC,TC,TC, TC,TC,TC,TC,
107107
],
108108
_ => throw new NotImplementedException(),
109109
},
110110
5 => byteOrder switch
111+
{
112+
0 => [
113+
RC,RC,RC,RC, RC,RC,EC,EC,
114+
GC,GC,GC,GC, GC,GC,EC,EC,
115+
BC,BC,BC,BC, BC,BC,EC,EC,
116+
TC,TC,TC,TC, TC,TC,TC,TC,
117+
],
118+
1 => [
119+
BC,BC,BC,BC, BC,BC,EC,EC,
120+
GC,GC,GC,GC, GC,GC,EC,EC,
121+
RC,RC,RC,RC, RC,RC,EC,EC,
122+
TC,TC,TC,TC, TC,TC,TC,TC,
123+
],
124+
_ => throw new NotImplementedException(),
125+
},
126+
6 => byteOrder switch
111127
{
112128
0 => [
113129
RC,RC,RC,RC, RC,RC,RC,RC,
@@ -123,7 +139,7 @@ public static SolidColorBrush[] GetOrderColors(int colorMode, int fullColor, int
123139
],
124140
_ => throw new NotImplementedException(),
125141
},
126-
6 => byteOrder switch
142+
7 => byteOrder switch
127143
{
128144
0 => [
129145
YC,YC,YC,YC, YC,YC,YC,YC,
@@ -139,7 +155,7 @@ public static SolidColorBrush[] GetOrderColors(int colorMode, int fullColor, int
139155
],
140156
_ => throw new NotImplementedException(),
141157
},
142-
7 => byteOrder switch
158+
8 => byteOrder switch
143159
{
144160
0 => [
145161
RC,RC,RC,RC, RC,RC,RC,RC,
@@ -391,41 +407,37 @@ public static string[] GetOrderChars(int colorMode, int colorDepth, int fullColo
391407
},
392408
4 => internalOrder switch
393409
{
394-
0 => byteOrder switch
395-
{
396-
0 => [
397-
"-", "-", "-", "-", "-", "-", "5", "4",
398-
"3", "2", "1", "0", "5", "4", "3", "2",
399-
"1", "0", "5", "4", "3", "2", "1", "0",
410+
0 => [
411+
"-", "-", "5", "4", "3", "2", "1", "0",
412+
"-", "-", "5", "4", "3", "2", "1", "0",
413+
"-", "-", "5", "4", "3", "2", "1", "0",
400414
"0", "0", "0", "0", "0", "0", "0", "0",
401415
],
402-
1 => [
403-
"1", "0", "5", "4", "3", "2", "1", "0",
404-
"3", "2", "1", "0", "5", "4", "3", "2",
405-
"-", "-", "-", "-", "-", "-", "5", "4",
416+
1 => [
417+
"-", "-", "0", "1", "2", "3", "4", "5",
418+
"-", "-", "0", "1", "2", "3", "4", "5",
419+
"-", "-", "0", "1", "2", "3", "4", "5",
406420
"0", "0", "0", "0", "0", "0", "0", "0",
407421
],
408-
_ => throw new NotImplementedException(),
409-
},
410-
1 => byteOrder switch
411-
{
412-
0 => [
413-
"-", "-", "-", "-", "-", "-", "0", "1",
414-
"2", "3", "4", "5", "0", "1", "2", "3",
415-
"4", "5", "0", "1", "2", "3", "4", "5",
422+
_ => throw new NotImplementedException(),
423+
},
424+
5 => internalOrder switch
425+
{
426+
0 => [
427+
"5", "4", "3", "2", "1", "0", "-", "-",
428+
"5", "4", "3", "2", "1", "0", "-", "-",
429+
"5", "4", "3", "2", "1", "0", "-", "-",
416430
"0", "0", "0", "0", "0", "0", "0", "0",
417431
],
418-
1 => [
419-
"4", "5", "0", "1", "2", "3", "4", "5",
420-
"2", "3", "4", "5", "0", "1", "2", "3",
421-
"-", "-", "-", "-", "-", "-", "0", "1",
432+
1 => [
433+
"0", "1", "2", "3", "4", "5", "-", "-",
434+
"0", "1", "2", "3", "4", "5", "-", "-",
435+
"0", "1", "2", "3", "4", "5", "-", "-",
422436
"0", "0", "0", "0", "0", "0", "0", "0",
423437
],
424-
_ => throw new NotImplementedException(),
425-
},
426438
_ => throw new NotImplementedException(),
427439
},
428-
<= 7 => internalOrder switch
440+
<= 8 => internalOrder switch
429441
{
430442
0 => [
431443
"7", "6", "5", "4", "3", "2", "1", "0",

Image2Display/Image2Display/Helpers/ColorData.cs

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,42 @@ public static List<byte> GetRGB666HighEmptyImage(Image<Rgba32> img, int rotate,
305305
g = (byte)ReverseBits(g, 6);
306306
b = (byte)ReverseBits(b, 6);
307307
}
308-
byte temp1 = (byte)(r >> 4);
309-
byte temp2 = (byte)(r << 4);
310-
temp2 |= (byte)(g >> 2);
311-
byte temp3 = (byte)(g << 6);
312-
temp3 |= b;
308+
309+
if (isSmallEndian)
310+
{
311+
l.Add(b);
312+
l.Add(g);
313+
l.Add(r);
314+
}
315+
else
316+
{
317+
l.Add(r);
318+
l.Add(g);
319+
l.Add(b);
320+
}
321+
});
322+
323+
return l;
324+
}
325+
326+
public static List<byte> GetRGB666LowEmptyImage(Image<Rgba32> img, int rotate, bool reverseBits, bool isSmallEndian)
327+
{
328+
var l = new List<byte>();
329+
330+
IterateImg(img, rotate, (color) =>
331+
{
332+
byte r = (byte)(color.R >> 2);
333+
byte g = (byte)(color.G >> 2);
334+
byte b = (byte)(color.B >> 2);
335+
if (reverseBits)
336+
{
337+
r = (byte)ReverseBits(r, 6);
338+
g = (byte)ReverseBits(g, 6);
339+
b = (byte)ReverseBits(b, 6);
340+
}
341+
byte temp1 = (byte)(r << 2);
342+
byte temp2 = (byte)(g << 2);
343+
byte temp3 = (byte)(b << 2);
313344

314345
if (isSmallEndian)
315346
{

Image2Display/Image2Display/ViewModels/ImageConvertViewModel.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public int[] IsByteShow
3939
{
4040
0 => [25, 25, 0],
4141
<= 3 => [25, 0, 0],
42-
<= 5 => [25, 25, 0],
43-
<= 7 => [25, 25, 25],
42+
<= 6 => [25, 25, 0],
43+
<= 8 => [25, 25, 25],
4444
_ => throw new NotImplementedException(),
4545
};
4646
}
@@ -218,13 +218,16 @@ await Task.Run(() =>
218218
4 => ColorData.GetRGB666HighEmptyImage(
219219
Image!.Raw, PixelTraversalOrder, ColorInternalOrder == 1,
220220
ByteOrder == 1),
221-
5 => ColorData.GetRGB888Image(
221+
5 => ColorData.GetRGB666LowEmptyImage(
222222
Image!.Raw, PixelTraversalOrder, ColorInternalOrder == 1,
223223
ByteOrder == 1),
224-
6 => ColorData.GetARGB8888Image(
224+
6 => ColorData.GetRGB888Image(
225225
Image!.Raw, PixelTraversalOrder, ColorInternalOrder == 1,
226226
ByteOrder == 1),
227-
7 => ColorData.GetRGBA8888Image(
227+
7 => ColorData.GetARGB8888Image(
228+
Image!.Raw, PixelTraversalOrder, ColorInternalOrder == 1,
229+
ByteOrder == 1),
230+
8 => ColorData.GetRGBA8888Image(
228231
Image!.Raw, PixelTraversalOrder, ColorInternalOrder == 1,
229232
ByteOrder == 1),
230233
_ => throw new NotImplementedException(),

Image2Display/Image2Display/Views/ImageConvertView.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@
587587
<ComboBoxItem Content="{DynamicResource RGB565}" />
588588
<ComboBoxItem Content="{DynamicResource RGB555High}" />
589589
<ComboBoxItem Content="{DynamicResource RGB666High}" />
590+
<ComboBoxItem Content="{DynamicResource RGB666Low}" />
590591
<ComboBoxItem Content="{DynamicResource RGB888}" />
591592
<ComboBoxItem Content="{DynamicResource ARGB8888}" />
592593
<ComboBoxItem Content="{DynamicResource RGBA8888}" />

0 commit comments

Comments
 (0)