How do you set the color of a pixel under the cursor on a FMX.Canvas?

With vcl I used this:

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;

How can I set the color at X,Y from a FMX Canvas?

Answers


According to this example, this should work:

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; 

Note that the mapping strategy with locking/unlocking the bitmap was introduced in FM2, i.e. Delphi-XE3.


Need Your Help

how can i get all the available messages on a MSMQ Queue

c# .net msmq

Whats the best way to get all the messages currently on a queue to process?