Einzelnen Beitrag anzeigen

Athris

Registriert seit: 18. Nov 2014
28 Beiträge
 
Delphi XE2 Professional
 
#4

AW: Verwirrung um TImage und den DPI Wert

  Alt 19. Okt 2017, 08:26
Also verstehe ich das richtig, dass der unter EIGENSCHAFTEN aufgelistete DPI Wert nur ein Hinweiswert für z.B. eine Applikation oder ein Drucker ist?

Das heißt ich müsste bei der Neuerstellung eines Bildes den Benutzer nach dem gewünschten DPI Wert fragen und diese beim Speichern des Bildes in die Datei reinschreiben?

Grundsätzlich speichere ich meine Bilder zurzeit so:
Delphi-Quellcode:
function SaveImage(vstrImagePath: String; vpntImage: TPicture): boolean;
var
  strDateiendung: string;
  pntBitmap: TBitmap;
  pntJPEGImage: TJPEGImage;
  pntPNGImage: TPngImage;
begin
  Result := False;
  pntBitmap := TBitmap.Create;
  try
    try
      pntBitmap.Assign(vpntImage);
      strDateiendung := UpperCase(ExtractFileExt(vstrImagePath));
      if strDateiendung = '.BMPthen begin
        pntBitmap.SaveToFile(vstrImagePath);
        Result := True
      end
      else if strDateiendung = '.PNGthen begin
        pntPNGImage := TPngImage.Create();
        try
          pntPNGImage.Assign(pntBitmap);
          pntPNGImage.SaveToFile(vstrImagePath);
          Result := True;
        finally
          pntPNGImage.Free;
        end;
      end
      else if (strDateiendung = '.JPG') or (strDateiendung = '.JPEG') then begin
        pntJPEGImage := TJPEGImage.Create();
        try
          pntJPEGImage.Assign(pntBitmap);
          pntJPEGImage.SaveToFile(vstrImagePath);
          Result := True;
        finally
          pntJPEGImage.Free;
        end;
      end;
    except on
      E:Exception do begin
        MessageDlg('Fehler beim Speichern der Grafikdatei '+vstrImagePath+': '+E.Message, mtError, [mbOk], 0);
      end;
    end;
  finally
    pntBitmap.Free;
  end;
  Mit Zitat antworten Zitat