AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Bitmap mit bestimmter DPI erstellen
Thema durchsuchen
Ansicht
Themen-Optionen

Bitmap mit bestimmter DPI erstellen

Ein Thema von TUX_der_Pinguin · begonnen am 15. Mai 2009 · letzter Beitrag vom 19. Mai 2009
 
TUX_der_Pinguin

Registriert seit: 1. Jun 2005
Ort: Anholt (NRW)
609 Beiträge
 
Delphi 11 Alexandria
 
#16

Re: Bitmap mit bestimmter DPI erstellen

  Alt 19. Mai 2009, 11:07
Ein Versuch die Grafikqualität zu erhöhen. Ich habe einen Versuch gestartet das ganze mit MetaFile umzusetzen, die Qualität
ist da durch auch enorm gestiegen. Jedoch ist das MetaFile auch irgendwie pixelig und nachher im Report/PDF auch.

Die Dateigröße des PDF ist auch viel zu viel, ein Ausdruck mit einem PDF drucker brachte eine Dateigröße von ca. 40 KB
und der Weg über den Rave Report bringt eine Datei mit einer größe von > 400 KB.

Delphi-Quellcode:
procedure TfrmGraph.RvCustConTAGraphGetRow(Connection: TRvCustomConnection);
var
  MemStream : TMemoryStream;
  DotsPerInch : Word;
  Wmf : TMetaFile;
  WmfCanvas : TMetaFileCanvas;

begin
  //init
  DotsPerInch := RvRenderPDF.MetafileDPI;

  Wmf := TMetaFile.Create;
  try
    try
      //Größe
      Wmf.SetSize(fMmToPx(1800, DotsPerInch), fMmToPx(1220, DotsPerInch));
      
      //Zeichenfläche erstellen
      WmfCanvas := TMetaFileCanvas.Create(Wmf, 0);
      try

        //Bild 1
        with Graph1.Draw do begin
          Pos.Left := fMmToPx(40, DotsPerInch);
          Pos.Top := fMmToPx(50, DotsPerInch);
          Pos.Width := fMmToPx(850, DotsPerInch);
          Pos.Height := fMmToPx(550, DotsPerInch);

          Margin.Top := fMmToPx(50, DotsPerInch); //Abstand zum oberen Rand
          Margin.Left := fMmToPx(120, DotsPerInch); //Abstand zum linken Rand
          Margin.Right := fMmToPx(90, DotsPerInch); //Abstand zum rechten Rand
          Margin.Bottom := fMmToPx(50, DotsPerInch); //Abstand zum unteren Rand

          Font := TFont.Create;
          Font.Name := 'Arial';
          Font.Height := fMmToPx(32, DotsPerInch);
          Font.Style := [];

          LabelDist.X := fMmToPx(10, DotsPerInch);
          LabelDist.Y := fMmToPx(10, DotsPerInch);

          DPI.Horz := DotsPerInch;
          DPI.Vert := DotsPerInch;
        end;{with Graph1.Draw}

        //Bild 2
        with Graph2.Draw do begin
          Pos.Left := fMmToPx(870+40, DotsPerInch);
          Pos.Top := fMmToPx(50, DotsPerInch);
          Pos.Width := fMmToPx(850, DotsPerInch);
          Pos.Height := fMmToPx(550, DotsPerInch);

          Margin.Top := fMmToPx(50, DotsPerInch); //Abstand zum oberen Rand
          Margin.Left := fMmToPx(120, DotsPerInch); //Abstand zum linken Rand
          Margin.Right := fMmToPx(90, DotsPerInch); //Abstand zum rechten Rand
          Margin.Bottom := fMmToPx(50, DotsPerInch); //Abstand zum unteren Rand

          Font := TFont.Create;
          Font.Name := 'Arial';
          Font.Height := fMmToPx(32, DotsPerInch);
          Font.Style := [];

          LabelDist.X := fMmToPx(10, DotsPerInch);
          LabelDist.Y := fMmToPx(10, DotsPerInch);

          DPI.Horz := DotsPerInch;
          DPI.Vert := DotsPerInch;
        end;{with}

        //Bild 3
        with Graph3.Draw do begin
          Pos.Left := fMmToPx(40, DotsPerInch);
          Pos.Top := fMmToPx(570+50, DotsPerInch);
          Pos.Width := fMmToPx(1720, DotsPerInch);
          Pos.Height := fMmToPx(550, DotsPerInch);

          Margin.Top := fMmToPx(50, DotsPerInch); //Abstand zum oberen Rand
          Margin.Left := fMmToPx(120, DotsPerInch); //Abstand zum linken Rand
          Margin.Right := fMmToPx(90, DotsPerInch); //Abstand zum rechten Rand
          Margin.Bottom := fMmToPx(50, DotsPerInch); //Abstand zum unteren Rand

          Font := TFont.Create;
          Font.Name := 'Arial';
          Font.Height := fMmToPx(32, DotsPerInch);
          Font.Style := [];

          LabelDist.X := fMmToPx(10, DotsPerInch);
          LabelDist.Y := fMmToPx(10, DotsPerInch);

          DPI.Horz := DotsPerInch;
          DPI.Vert := DotsPerInch;
        end;{with}

        //Grafik zeichnen...
        pGraph_Draw(WmfCanvas, False, True);

      finally
        WmfCanvas.Free;
      end;

      Wmf.SaveToFile(glLocalAppDir+'bla.wmf'); //Die Datei ist ca. 507 KB groß

      //Bild in Report laden...
      MemStream := TMemoryStream.Create;
      try
        Wmf.SaveToStream(MemStream);
        Connection.WriteBlobData(MemStream.Memory^, MemStream.Size);
      finally
        MemStream.Free;
      end;

    except
      on EOutOfResources do begin
        Application.MessageBox(PAnsiChar(fGetText(10212)), PAnsiChar(fGetText(MSG_ERROR)), 48);
        //Close;
      end;
    end;{try..except}

  finally
    Wmf.Free;
  end;{try..finally}

end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:14 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz