Autor Beitrag
Jukka
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 107

Win XP Pro
Delphi 7
BeitragVerfasst: Do 07.09.06 19:31 
Hallo ich wollte fragen ob soetwas schwer ist:

Ich habe eine Datei und die dazugehörige struktur des headers etc. Nun möchte ich das auslesen:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
* - Field - Size - Type  - Description
0 - Header - 2 bytes - char - AC
2 - Major version - 1 bytes - Byte - See Below
3 - Minor Version - 1 byte - Byte - See Below
4 - Images Count - 1 byte - Integer - Nº of images contained
{ Image (Header offset +14)
10 - Size X - 2 bytes Integer - Size of field (LB HB format)
12 - Size Y - 2 bytes Integer - Size of field (LB HB format)
14 - Len Data - 2 bytes Integer – Length of field data (LB HB format)
16-(16+Len Data) - Frame data*
}
- - Palette - 1024 bytes - RGB - 256 color palette

Frame Data
Image pixels indexed with 256 color palette, first palette color is background. Only background pixels are compresed in RLE, compresion can go beyond rows.


Das ist der aufbau einer normalen .spr Datei ( eine datei in der meherebilder zusammengefasst werden). Den aufbau hab ich bei suchnen von google mal gefunden

ich will halt fragen ob eine funktion wie:

function GetSPRImage(filename:string,imageposition:integer):TImage;

schwer ist, die funktion soll das bild an stelle "imageposition" aus "filename" anzeigen. Ist soetwas nur schwer möglich oder anders?

MfG Ju
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 11.09.06 22:27 
Kommt drauf an, ob neben dem Header noch weitere Strukturen in der Datei verwendet werden ...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
* - Field - Size - Type  - Description
0 - Header - 2 bytes - char - AC
2 - Major version - 1 bytes - Byte - See Below
3 - Minor Version - 1 byte - Byte - See Below
4 - Images Count - 1 byte - Integer - Nº of images contained
{ Image (Header offset +14)
10 - Size X - 2 bytes Integer - Size of field (LB HB format)
12 - Size Y - 2 bytes Integer - Size of field (LB HB format)
14 - Len Data - 2 bytes Integer – Length of field data (LB HB format)
16-(16+Len Data) - Frame data*
}

- - Palette - 1024 bytes - RGB - 256 color palette

Frame Data
Image pixels indexed with 256 color palette, first palette color is background. Only background pixels are compresed in RLE, compresion can go beyond rows.


lässt sich IMHO so hier zusammenfassen:
ausblenden Hauptheader:
1:
2:
3:
4:
5:
6:
7:
type
  TSPRImage_Header = packed record
    SPRMagic: Word; //Should be $6361
    SPRMajor: Byte; //Major version
    SPRMinor: Byte; //Minor version
    ImgCount: Byte; //Number of pictures
  end;


ausblenden Bildheader:
1:
2:
3:
4:
5:
6:
7:
type
  TSPRImage_ImgData = packed record
    ImgWidth: Word; //Width of the subimage
    ImgHeight: Word; //Height of the subimage
    DataLen: Word; //Length of the data portion
    Data: Record end; //Actual Image Data
  end;


Die RLE-Komprimierung zu realisieren ist relativ einfach, auch wenn sie nicht ganz offensichtlich ist ... Das Lesen der Palette am Ende geht über folgendes Array zu realisieren:
ausblenden Delphi-Quelltext
1:
2:
Type
  TSPRImage_Palette: packed Array[Byte] of TColor;


Wenn man dann noch beachtet, dass meine Header-Deklarationen bei den einzelbildern keinen Platz für die Bilddaten mitreservieren, sollte das Lesen des Bildes mit etwa 50 Zeilen machbar sein.

Wobei mir nicht ganz klar ist, wie man bei der Background-RLE unterscheiden soll ... Dazu bräuchte man ne Beispiel-Datei ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Jukka Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 107

Win XP Pro
Delphi 7
BeitragVerfasst: Di 12.09.06 19:28 
Hm ja das mit den recods soweit kam ich auchschon jedoch wie kann ich diese direkt auslesen

Hab mal ein beispiel drangehängt, komtm aus programmen wie Playerworlds oder so, keine Ahnung wo ich grade das her hab
Einloggen, um Attachments anzusehen!