Delphi 如何在FMX.Canvas上设置光标下像素的颜色?

Delphi 如何在FMX.Canvas上设置光标下像素的颜色?,delphi,firemonkey,delphi-xe4,Delphi,Firemonkey,Delphi Xe4,对于vcl,我使用了以下方法: procedure MovingDots(X, Y: Integer; ACanvas: TCanvas); stdcall; begin {$R-} Inc(ALooper); ACounter := ACounter shl 1; // Shift the bit left one if ACounter = 0 then ACounter := 1; // If it shifts off left, reset it if (ACo

对于vcl,我使用了以下方法:

procedure MovingDots(X, Y: Integer; ACanvas: TCanvas); stdcall;
begin
{$R-}
  Inc(ALooper);
  ACounter := ACounter shl 1; // Shift the bit left one
  if ACounter = 0 then
    ACounter := 1; // If it shifts off left, reset it
  if (ACounter and 224) > 0 then // Are any of the left 3 bits set?
    // FMX.Canvas does not have Pixels
    ACanvas.Pixels[X, Y] := ASelectionColor1 // Erase the pixel
  else
    ACanvas.Pixels[X, Y] := ASelectionColor2; // Draw the pixel
{$R+}
end;
如何从FMX画布将颜色设置为X,Y?

根据这一点,应该可以:

var
  vBitMapData : TBitmapData;
  ASelectionColor : TAlphaColor;
...
// Define ASelectionColor somewhere
// Get write access to the bitmap
if ACanvas.Bitmap.Map (TMapAccess.maWrite, vBitMapData) then
begin
  try
    vBitmapData.SetPixel (x, y, ASelectionColor); // set the pixel color at x, y
  finally
    ACanvas.Bitmap.Unmap(vBitMapData);
  end;
end; 

请注意,带有锁定/解锁位图的映射策略是在FM2(即Delphi-XE3)中引入的。

非常感谢您,但您应该将这些添加到您想说谢谢的问题的注释中,而不是在其他问题的主体中。@DavidHeffernan,这不是正确的吗?哦,天哪,我好像是瞎子。昨天,当我得出结论说
TCanvas
没有
Bitmap
属性时,我就快要写出完全相同的答案了。哦,好吧。至少你的眼睛还能用+1.