Skip to content

Commit

Permalink
AC18
Browse files Browse the repository at this point in the history
  • Loading branch information
DomCR committed Oct 28, 2023
1 parent ef180c7 commit 9c523f6
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions ACadSharp/IO/DWG/DwgStreamReaders/DwgStreamReaderAC18.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Drawing;
using CSUtilities.Converters;
using System.Drawing;
using System.IO;

namespace ACadSharp.IO.DWG
Expand All @@ -18,12 +19,12 @@ public override Color ReadCmColor()
//BL: RGB value
//Always negative
uint rgb = (uint)this.ReadBitLong();
byte[] arr = LittleEndianConverter.Instance.GetBytes(rgb);

if ((rgb & 0b1000000000000000000000000) != 0)
if ((rgb & 0b0000_0001_0000_0000_0000_0000_0000_0000) != 0)
{
//Indexed color
uint index = (uint)((int)rgb + 0b1100_0011_0000_0000_0000_0000_0000_0000);
color = new Color((byte)index);
color = new Color(arr[0]);
}
else
{
Expand All @@ -34,13 +35,7 @@ public override Color ReadCmColor()
//0xC0000000

//True color
uint trueColor = (uint)((int)rgb - 0b1100_0010_0000_0000_0000_0000_0000_0000);

//Needs the check just in case the flag is not set
if (trueColor < 1 << 24)
{
color = Color.FromTrueColor(trueColor);
}
color = new Color(arr[0], arr[1], arr[2]);
}

//RC: Color Byte(&1 => color name follows(TV),
Expand Down

0 comments on commit 9c523f6

Please sign in to comment.