Thema: WMF To PNG

Einzelnen Beitrag anzeigen

Redeemer

Registriert seit: 19. Jan 2009
Ort: Kirchlinteln (LK Verden)
1.045 Beiträge
 
Delphi 2009 Professional
 
#7

AW: WMF To PNG

  Alt 8. Jun 2024, 22:53
Die 8 sind pro Kanal. PNG kann keine 16-Bit insgesamt.

Graphic ist dein EMF. Der Rest ist klar. Das Ergebnis heißt TempPNG.
Delphi-Quellcode:
        TempPNG := TPNGImage.CreateBlank(COLOR_RGBALPHA, 8, Graphic.Width * Supersample, Graphic.Height * Supersample);
        TempPNG2 := TPNGImage.CreateBlank(COLOR_RGB, 8, Graphic.Width * Supersample, Graphic.Height * Supersample);
        try
          TempPNG.Canvas.Brush.Color := clBlack;
          TempPNG2.Canvas.Brush.Color := clWhite;
          TempPNG.Canvas.FillRect(Rect(0, 0, Graphic.Width * Supersample, Graphic.Height * Supersample));
          TempPNG2.Canvas.FillRect(Rect(0, 0, Graphic.Width * Supersample, Graphic.Height * Supersample));
          TempPNG.Canvas.StretchDraw(Rect(0, 0, Graphic.Width * Supersample, Graphic.Height * Supersample), Graphic);
          TempPNG2.Canvas.StretchDraw(Rect(0, 0, Graphic.Width * Supersample, Graphic.Height * Supersample), Graphic);
          for y := 0 to TempPNG.Height - 1 do
          begin
            ScanLine := TempPNG.AlphaScanline[y];
            for x := 0 to TempPNG.Width - 1 do
            ScanLine^[x] := Byte((TempPNG.Pixels[x,y] = TempPNG2.Pixels[x,y])) * 255;
          end;
        finally
          TempPNG2.Free;
        end;
Ein FillRect (und das Setzen der Brush-Farbe davor) wäre unnötig, wenn man wüsste, was die Standardfarbe von TPngImage ist.
Janni
2005 PE, 2009 PA, XE2 PA
  Mit Zitat antworten Zitat