TACHART TManhattanSeries red and blue color bits are switched.
Original Reporter info from Mantis: ArmandsM
-
Reporter name: Armands Murans
Original Reporter info from Mantis: ArmandsM
- Reporter name: Armands Murans
Description:
If you use tachart with TManhattanSeries then using blue color you get red and vice versa.
Steps to reproduce:
Create simple project with Tachart and TManhattanSeries .
Use blue as the only color.
You will get red.
//===========
Use red as the only color.
You will get blue.
Additional information:
It is possible to swap back colors in right order.
procedure TManhattanSeries.Draw(ADrawer: IChartDrawer);
var
img: TLazIntfImage;
topLeft, pt: TPoint;
i, cnt: Integer;
ext: TDoubleRect;
rawImage: TRawImage;
r: TRect;
// n1,n2:integer;
procedure PutPixel2(const APoint: TPoint; AColor: TColor); inline;
begin
PCardinal(rawImage.Data)[APoint.Y * r.Right + APoint.X] := Cardinal(ColorDef(AColor, SeriesColor)) or $FF000000; // Opacity.
// PCardinal(rawImage.Data)[APoint.Y * r.Right + APoint.X] := Cardinal(AColor) or $FF000000; // Opacity.
cnt += 1;
end;
function SwapRedBlue(AColor: TColor): TColor;inline;
var
R, G, B: Byte;
begin
RedGreenBlue(AColor, R, G, B);
Result := RGBToColor(B, G, R);
end;
begin
with Extent do begin
ext.a := AxisToGraph(a);
ext.b := AxisToGraph(b);
end;
NormalizeRect(ext);
if not RectIntersectsRect(ext, ParentChart.CurrentExtent) then exit;
// Do not cache graph points to reduce memory overhead.
FindExtentInterval(ext, true);
topLeft := ParentChart.ClipRect.TopLeft;
r := BoundsSize(0, 0, ParentChart.ClipRect.BottomRight - topLeft);
cnt := 0;
img := CreateLazIntfImage(rawImage, r.BottomRight);
// n1:=0;
// n2:=0;
try
// AxisToGraph is slow, so split loop to optimize non-transformed case.
if (AxisIndexX = -1) and (AxisIndexY = -1) then
for i := FLoBound to FUpBound do
with Source[i]^ do begin
pt := ParentChart.GraphToImage(Point) - topLeft;
if PtInRect(r, pt) then
PutPixel2(pt, SwapRedBlue(Color));
// n1:=n1+1;
end
else
for i := FLoBound to FUpBound do
with Source[i]^ do begin
pt := ParentChart.GraphToImage(AxisToGraph(Point)) - topLeft;
if PtInRect(r, pt) then
PutPixel2(pt, SwapRedBlue(Color));
// n2:=n2+1;
end;
if cnt > 0 then
ADrawer.PutImage(topLeft.X, topLeft.Y, img);
finally
img.Free;
end;
// showmessage('n1='+Inttostr(n1)+' n2='+IntTostr(n2));
end;