AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Multimedia Delphi Bildgröße von Bilddateien

Bildgröße von Bilddateien

Ein Thema von Tpercon · begonnen am 13. Jul 2002 · letzter Beitrag vom 1. Aug 2002
Antwort Antwort
Seite 2 von 4     12 34   
Benutzerbild von movax
movax

Registriert seit: 12. Jul 2002
Ort: phobos
15 Beiträge
 
#11
  Alt 18. Jul 2002, 11:09
also dann.. ich hab mich mal hingesetzt und schnell was für dich zusammengeschustert:

Code:
[b]procedure[/b] TForm1.Button1Click(Sender: TObject);
[b]var[/b]
  gif: integer;
  dmy: [b]array[/b][0..3] [b]of[/b] Char;
  Width, Height: integer;
[b]begin[/b]
 gif := FileOpen('blabla.gif');
 FileSeek(gif, 6, 0); [color=#000080][i]//<- man könnte hier noch testen, ob
                   //   davor der GIF-Tag in der Datei
                   //   steht..[/i][/color]
 FileRead(Gif,dmy,4);
 FileCLose(gif);
 Width := ord(dmy[1]) * 256 + ord(dmy[0]); [color=#000080][i]//<- die hex-werte umwandeln[/i][/color]
 Height := ord(dmy[3]) * 256 + ord(dmy[2]);
[b]end[/b];
so, jetzt hast du in den Variablen Width und Height die Breite und die Höhe des GIF-Bilds (sofern es ein GIF89-konformes GIF ist )

Ich hoffe, das hilft dir weiter.. Der Code prüft übrigens nicht, ob's sich bei der datei wirklich um ein GIF handelt, dazu brauchst du aber nur testen, ob die ersten 3 bzw. 5 bytes 'GIF' bzw. 'GIF89' sind

greetz,
-movax-

|movax.rult.de
  Mit Zitat antworten Zitat
Benutzerbild von sakura
sakura

Registriert seit: 10. Jun 2002
Ort: München
11.412 Beiträge
 
Delphi 11 Alexandria
 
#12
  Alt 18. Jul 2002, 11:11
@movax: Ich bin mir sicher: Tpercon wirds danken.
Daniel W.
Ich bin nicht zurück, ich tue nur so
  Mit Zitat antworten Zitat
Tpercon

Registriert seit: 7. Jun 2002
638 Beiträge
 
Delphi 5 Professional
 
#13
  Alt 18. Jul 2002, 18:16
Danke sakura für die Erklärung! Und natürlich auch an movax ein Danke.
Dann werde ich fürs jpeg wohl nicht drum rum kommen, die Unit jpeg (macht das Prog ca. 90 kB größer ) mit einzubinden.
Hat jemand sonst zu den anderen Formaten (.png) ne Idee oder so ne gute Erklärung?
  Mit Zitat antworten Zitat
Tpercon

Registriert seit: 7. Jun 2002
638 Beiträge
 
Delphi 5 Professional
 
#14
  Alt 19. Jul 2002, 21:03
Hi

Die Breiten und Höhenangabe steht beim Icon beim 6. und 7. Byte, beim png vom 16.- 19. und 20. - 23. Byte.
Beim jpeg muß da doch auch irgend ne Regelmäßigkeit sein?!
  Mit Zitat antworten Zitat
Benutzerbild von sakura
sakura

Registriert seit: 10. Jun 2002
Ort: München
11.412 Beiträge
 
Delphi 11 Alexandria
 
#15
  Alt 20. Jul 2002, 08:34
Eine Regelmäßigkeit gibts schon, aber die hat ein paar verschiedene Abhängigkeiten...
Code:
JPEG/JFIF file format:
~~~~~~~~~~~~~~~~~~~~~~

  - header (2 bytes): $ff, $d8 (SOI) (these two identify a JPEG/JFIF file)
  - for JFIF files, an APP0 segment is immediately following the SOI marker, see below
  - any number of "segments" (similar to IFF chunks), see below
  - trailer (2 bytes): $ff, $d9 (EOI)

Segment format:
~~~~~~~~~~~~~~~

  - header (4 bytes):
       $ff    identifies segment
        n     type of segment (one byte)
       sh, sl size of the segment, including these two bytes, but not
               including the $ff and the type byte. Note, not Intel order:
               high byte first, low byte last!
  - contents of the segment, max. 65533 bytes.

 Notes:
  - There are parameterless segments (denoted with a '*' below) that DON'T
    have a size specification (and no contents), just $ff and the type byte.
  - Any number of $ff bytes between segments is legal and must be skipped.

Segment types:
~~~~~~~~~~~~~~

   *TEM  = $01   usually causes a decoding error, may be ignored
    SOF0  = $c0   Start Of Frame (baseline JPEG), for details see below
    SOF1  = $c1   dito
    SOF2  = $c2   usually unsupported
    SOF3  = $c3   usually unsupported

    SOF5  = $c5   usually unsupported
    SOF6  = $c6   usually unsupported
    SOF7  = $c7   usually unsupported

    SOF9  = $c9   for arithmetic coding, usually unsupported
    SOF10 = $ca  usually unsupported
    SOF11 = $cb  usually unsupported

    SOF13 = $cd  usually unsupported
    SOF14 = $ce  usually unsupported
    SOF14 = $ce  usually unsupported
    SOF15 = $cf  usually unsupported

    DHT  = $c4   Define Huffman Table, for details see below
    JPG  = $c8   undefined/reserved (causes decoding error)
    DAC  = $cc  Define Arithmetic Table, usually unsupported

   *RST0  = $d0   RSTn are used for resync, may be ignored
   *RST1  = $d1
   *RST2  = $d2
   *RST3  = $d3
   *RST4  = $d4
   *RST5  = $d5
   *RST6  = $d6
   *RST7  = $d7

    SOI  = $d8   Start Of Image
    EOI  = $d9   End Of Image
    SOS  = $da  Start Of Scan, for details see below
    DQT  = $db  Define Quantization Table, for details see below
    DNL  = $dc  usually unsupported, ignore

    SOI  = $d8   Start Of Image
    EOI  = $d9   End Of Image
    SOS  = $da  Start Of Scan, for details see below
    DQT  = $db  Define Quantization Table, for details see below
    DNL  = $dc  usually unsupported, ignore
    DRI  = $dd  Define Restart Interval, for details see below
    DHP  = $de  ignore (skip)
    EXP  = $df  ignore (skip)

    APP0  = $e0   JFIF APP0 segment marker, for details see below
    APP15 = $ef  ignore

    JPG0  = $f0   ignore (skip)
    JPG13 = $fd  ignore (skip)
    COM  = $fe  Comment, for details see below

 All other segment types are reserved and should be ignored (skipped).

SOF0: Start Of Frame 0:
~~~~~~~~~~~~~~~~~~~~~~~

  - $ff, $c0 (SOF0)
  - length (high byte, low byte), 8+components*3
  - data precision (1 byte) in bits/sample, usually 8 (12 and 16 not
    supported by most software)
  - image height (2 bytes, Hi-Lo), must be >0 if DNL not supported
  - image width (2 bytes, Hi-Lo), must be >0 if DNL not supported
  - number of components (1 byte), usually 1 = grey scaled, 3 = color YCbCr
    or YIQ, 4 = color CMYK)
  - for each component: 3 bytes
     - component id (1 = Y, 2 = Cb, 3 = Cr, 4 = I, 5 = Q)
     - sampling factors (bit 0-3 vert., 4-7 hor.)
     - quantization table number
Das heisst, Du musst zuerst das Segment finden, welches mit dem Marker 0xFFC0 markiert ist, und das muss nicht das erste Segment sein, da dort auch andere Informationen gespeichert sein können. in diesem Segment musst Du Byte 5 und 6 für die Höhe lesen und Byte 7 und 8 für die Breite.

Code:
NOTE: The JPEG/JFIF file format uses Motorola format for words, NOT Intel format,
i.e. : high byte first, low byte last -- (ex: the word FFA0 will be written in
the JPEG file in the order : FF at the low offset , A0 at the higher offset)
Daniel W.
Ich bin nicht zurück, ich tue nur so
  Mit Zitat antworten Zitat
Tpercon

Registriert seit: 7. Jun 2002
638 Beiträge
 
Delphi 5 Professional
 
#16
  Alt 22. Jul 2002, 16:35
Hi

Kann das sein, dass jpeg Dateien FFC2 haben und jpg FFC0?
So ist das nämlich bei den Dateien bei mir!? Wenn das immer so wäre, dann kann ich die jetzt auch erfolgreich auslesen.

Gruß
  Mit Zitat antworten Zitat
Benutzerbild von sakura
sakura

Registriert seit: 10. Jun 2002
Ort: München
11.412 Beiträge
 
Delphi 11 Alexandria
 
#17
  Alt 22. Jul 2002, 17:07
Eigentlich sollte es nicht so sein, aber wer weiss... Am besten erst nach 0xFFC0 suchen, und wenn es dieses nicht gibt nach 0xFFC2... Theoretisch kommt JPEG daher, dass seit Win95 die Dateiendung nicht mehr auf 3 Zeichen begrenzt ist und seit dem auch UNIX Dateinamen funktionieren...
Daniel W.
Ich bin nicht zurück, ich tue nur so
  Mit Zitat antworten Zitat
Tpercon

Registriert seit: 7. Jun 2002
638 Beiträge
 
Delphi 5 Professional
 
#18
  Alt 22. Jul 2002, 18:09
Habt ihr den jpeg Dateien wo das nicht C2 ist?
  Mit Zitat antworten Zitat
Christian Seehase
(Co-Admin)

Registriert seit: 29. Mai 2002
Ort: Hamburg
11.105 Beiträge
 
Delphi 11 Alexandria
 
#19
  Alt 22. Jul 2002, 18:12
Moin Tpercon,

also auf Dateiendungen würde ich mich prinzipiell nicht verlassen.
Zur exakten Feststellung des Dateityps sind i.d.R. die Headerinformationen in Dateien die diese bieten gedacht.
Tschüss Chris
Die drei Feinde des Programmierers: Sonne, Frischluft und dieses unerträgliche Gebrüll der Vögel.
Der Klügere gibt solange nach bis er der Dumme ist
  Mit Zitat antworten Zitat
Tpercon

Registriert seit: 7. Jun 2002
638 Beiträge
 
Delphi 5 Professional
 
#20
  Alt 22. Jul 2002, 18:23
Prinzipiell hast du natürlich recht!
Die ersten 10 Byte's sind bei beiden gleich. Mich würde es halt trotzdem interessieren.
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

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 09:42 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz