AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken Delphi Typ eines Blob Feldes Ermitteln
Thema durchsuchen
Ansicht
Themen-Optionen

Typ eines Blob Feldes Ermitteln

Ein Thema von DrNo · begonnen am 22. Mai 2010 · letzter Beitrag vom 23. Mai 2010
Antwort Antwort
Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#1

Re: Typ eines Blob Feldes Ermitteln

  Alt 23. Mai 2010, 06:35
Zitat von himitsu:
Zitat von DrNo:
Frage: Wie kann ich den Grafiktyp einer in einem BLOB gespeicherten
Grafik ermitteln ?
Indem du diese ausließt und analysierst, bzw. analysieren läßt.
Ansatz (ungetestet, unvollständig)

Delphi-Quellcode:
function GetImgFormatFromField(AField: TField): MyImageType;
var
  fldBLOB: TBlobField;
  MemStream: TMemoryStream;
  ImgGraphic: TGraphic;
  imgFormat: array[1..3] of char;
begin
  MyImageType := ImgUnknown;
  if (AField is TBlobField) then
  begin
    fldBLOB := TBlobField(AField);
    if not (fldBLOB.IsNull) then
    begin
      MemStream := TMemoryStream.Create();
      try
        fldBLOB.SaveToStream(MemStream);
        MemStream.Position := 0;
        if (MemStream.Size > 3) then
        begin
          MemStream.Read(imgFormat, 3);
          if (imgFormat[1] = 'B') and (imgFormat[2] = 'M') then
           MyImageType := // BMP
          else if (imgFormat[1] = 'G') and (imgFormat[2] = 'I') and (imgFormat[3] = 'F') then
           MyImageType := // GIF
          else if (imgFormat[1] = #$FF) and (imgFormat[2] = #$D8) and (imgFormat[3] = #$FF) then
           MyImageType := // JPEG
          else if (imgFormat[1] = 'E') and (imgFormat[2] = 'X') and (imgFormat[3] = 'I') then
           MyImageType := // EXIF
          else if (imgFormat[1] = #$D7) and (imgFormat[2] = #$CD) and (imgFormat[3] = #$C6) then
           MyImageType := // WMF
          else
           MyImageType := ImgUnknown// anderes Format
        end;
      finally
        MemStream.Free;
      end;
    end;
  end;
end;
Thomas
  Mit Zitat antworten Zitat
Antwort Antwort


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 15:17 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