Skip to content

Commit 4ddbe74

Browse files
author
Juan Segura
committed
- Fixed attribute bug in paste command
- Fixed import image bright mismatch
1 parent 3e0de1c commit 4ddbe74

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

ZXBStudio/DocumentEditors/ZXGraphics/SpriteImportDialog.axaml.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ private void _UpdatePreview()
330330
var dirAttr = (cy * sw) + cx;
331331
var attr = pattern.Attributes[dirAttr];
332332
attr.Bright = attr.Bright | (idxAttr > 7);
333-
byte cCol = (byte)(idxAttr & 0b111);
333+
byte cCol = (byte)(idxAttr /*& 0b111*/);
334334
if (paper == -1)
335335
{
336336
attr.Paper = cCol;
@@ -406,9 +406,10 @@ private void _UpdatePreview()
406406

407407
private int GetColor(byte r, byte g, byte b, PaletteColor[] palette)
408408
{
409-
if (r > 0)
409+
bool brigth = false;
410+
if (r > 250 || g > 250 || b > 250)
410411
{
411-
412+
brigth = true;
412413
}
413414
byte cr = GetColor_CutOff(r);
414415
byte cg = GetColor_CutOff(g);
@@ -428,6 +429,10 @@ private int GetColor(byte r, byte g, byte b, PaletteColor[] palette)
428429
palColor.Green == p.Green &&
429430
palColor.Blue == p.Blue)
430431
{
432+
if (brigth && n<8)
433+
{
434+
return n + 8;
435+
}
431436
return n;
432437
}
433438
}
@@ -471,9 +476,9 @@ private byte GetColor_CutOff(byte c)
471476

472477
private static double GetColorDistance(PaletteColor c1, PaletteColor c2)
473478
{
474-
int rDiff = c1.Red - c2.Red;
475-
int gDiff = c1.Green - c2.Green;
476-
int bDiff = c1.Blue - c2.Blue;
479+
int rDiff = Math.Abs(c1.Red - c2.Red);
480+
int gDiff = Math.Abs(c1.Green - c2.Green);
481+
int bDiff = Math.Abs(c1.Blue - c2.Blue);
477482
return Math.Sqrt(rDiff * rDiff + gDiff * gDiff + bDiff * bDiff);
478483
}
479484

ZXBStudio/DocumentEditors/ZXGraphics/SpritePatternEditor.axaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ public async void Paste()
561561
else
562562
{
563563
SpriteData.Patterns[SpriteData.CurrentFrame].RawData = cbPatterns[0].RawData;
564+
SpriteData.Patterns[SpriteData.CurrentFrame].Attributes = cbPatterns[0].Attributes;
564565
}
565566
}
566567
else

0 commit comments

Comments
 (0)