33 bool hasAlpha = img.HasAlpha();
36 for(
int y = 0; y < img.GetHeight(); y++ )
38 for(
int x = 0; x < img.GetWidth(); x++ )
40 int r = img.GetRed( x, y );
41 int g = img.GetGreen( x, y );
42 int b = img.GetBlue( x, y );
43 int a = hasAlpha ? img.GetAlpha( x, y ) : 255;
46 r = std::min( r >> roundBits << roundBits, 0xFF );
47 g = std::min( g >> roundBits << roundBits, 0xFF );
48 b = std::min( b >> roundBits << roundBits, 0xFF );
49 a = std::min( a >> roundBits << roundBits, 0xFF );
51 img.SetRGB( x, y, r, g, b );
54 img.SetAlpha( x, y, a );
58 std::unordered_map<uint32_t, SHAPE_POLY_SET> colorPolys;
61 for(
int y = 0; y < img.GetHeight(); y++ )
63 for(
int x = 0; x < img.GetWidth(); x++ )
65 uint32_t r = img.GetRed( x, y );
66 uint32_t g = img.GetGreen( x, y );
67 uint32_t b = img.GetBlue( x, y );
68 uint32_t a = hasAlpha ? img.GetAlpha( x, y ) : 255;
72 uint32_t color = r | ( g << 8 ) | ( b << 16 ) | ( a << 24 );
77 chain.Append( x * pixelScale.
x, y * pixelScale.
y,
true );
78 chain.Append( ( x + 1 ) * pixelScale.
x, y * pixelScale.
y,
true );
79 chain.Append( ( x + 1 ) * pixelScale.
x, ( y + 1 ) * pixelScale.
y,
true );
80 chain.Append( x * pixelScale.
x, ( y + 1 ) * pixelScale.
y,
true );
81 chain.SetClosed(
true );
88 for(
auto& [color, polySet] : colorPolys )
92 for(
int i = 0; i < polySet.OutlineCount(); i++ )
108 std::unordered_map<uint32_t, SHAPE_POLY_SET> colorPolys =
111 for(
auto& [color, polySet] : colorPolys )
119 shape->SetPolyShape( poly );
121 int r = color & 0xFF;
122 int g = ( color >> 8 ) & 0xFF;
123 int b = ( color >> 16 ) & 0xFF;
124 int a = ( color >> 24 ) & 0xFF;
126 shape->SetWidth( -1 );
128 shape->SetFillColor(
COLOR4D( r / 255.0, g / 255.0, b / 255.0, a / 255.0 ) );
130 shape->SetUnit( unit );
132 shape->Move( offset );