Einzelnen Beitrag anzeigen

TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.060 Beiträge
 
Delphi 10.4 Sydney
 
#2

AW: DrawBitmap Pixelated mit Firemonkey unter Android/GPUCanvas

  Alt 23. Mai 2016, 16:36
TCanvas ist unter Firemonkey ja nur eine Abstraktion.

Je nach Plattform und Einstellung wird dann eine konkrete Implementierung eingesetzt:
FMX.Canvas.D2D.TCanvasD2D für Windows mit Direct2D 1.0 Technologie, Android wird wohl den FMX.Canvas.GPU.TCanvasGpu bekommen. Daneben gibt es noch GDI+ in FMX.Canvas.GDIP.TCanvasGdiPlus und für Apple-Kram den FMX.Canvas.Mac.TCanvasQuartz.

Wenn du mal in die jeweilige Implementierung der verschiedenen Canvas-Klassen reinschaust, wirst du sehen, dass nur beim GPU-Canvas die Einstellung für HighSpeed ins Leere läuft und damit keine Auswirkung hat.


Delphi-Quellcode:
procedure TCanvasD2D.DoDrawBitmap(const ABitmap: TBitmap; const SrcRect, DstRect: TRectF; const AOpacity: Single;
  const HighSpeed: Boolean);
var
  SR, DR: TD2D1RectF;
  IntMode: TD2D1BitmapInterpolationMode;
  B: ID2D1Bitmap;
begin
  if FTarget <> nil then
  begin
    SR := D2Rect(SrcRect);
    DR := D2Rect(DstRect);

    if ABitmap.HandleAllocated then
    begin
      if HighSpeed then
        IntMode := D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR
      else
        IntMode := D2D1_BITMAP_INTERPOLATION_MODE_LINEAR;

      B := TD2DBitmapHandle(ABitmap.Handle).CreateBitmap(FTarget);
      if B <> nil then
        FTarget.DrawBitmap(B, @DR, AOpacity, IntMode, @SR);
    end;
  end;
end;
Delphi-Quellcode:
procedure TCanvasGpu.DoDrawBitmap(const ABitmap: TBitmap; const SrcRect, DstRect: TRectF; const AOpacity: Single;
  const HighSpeed: Boolean);
var
  B: TBitmapCtx;
  Bmp: TBitmap;
begin
  if FContext <> nil then
  begin
    Bmp := ABitmap;
    if Bmp.HandleAllocated then
    begin
      B := TBitmapCtx(Bmp.Handle);
      FCanvasHelper.TexRect(TransformBounds(CornersF(DstRect)), CornersF(SrcRect.Left, SrcRect.Top, SrcRect.Width,
        SrcRect.Height), B.PaintingTexture, PrepareColor(FModulateColor, AOpacity));
    end;
  end;
end;
  Mit Zitat antworten Zitat