AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Projekte [GAME] Bloggy [ALPHA Version 0.6] (Multiplayer.?.)
Thema durchsuchen
Ansicht
Themen-Optionen

[GAME] Bloggy [ALPHA Version 0.6] (Multiplayer.?.)

Ein Thema von olee · begonnen am 26. Feb 2008 · letzter Beitrag vom 5. Mär 2008
 
Benutzerbild von olee
olee

Registriert seit: 16. Feb 2008
Ort: Boppard
540 Beiträge
 
Turbo Delphi für Win32
 
#34

Re: [GAME] Bloggy [ALPHA Version 0.6] (Multiplayer.?.)

  Alt 4. Mär 2008, 23:15
@3_of_8 : Also bei mir lädt der das Bild nur in einen Pointer oder so. Hab keine ahnung, in welchem Format der das in dem Pointer speichert.

Delphi-Quellcode:
var
  FileHeader: TBITMAPFILEHEADER; // was FileHeader: BITMAPFILEHEADER; undeclared identifier
  InfoHeader: TBITMAPINFOHEADER; // was InfoHeader: BITMAPINFOHEADER; undeclared identifier
  Palette: array [byte] of TRGBQUAD; // Palette: array of RGBQUAD; declaration of array not supported by D2 and undeclared identifier RGBQUAD
  BitmapFile: THandle;
  BitmapLength: Integer; // changed from variant
  PaletteLength: Integer; // '' '' ''
  ReadBytes: Integer; // changed for incompatibility whith declaration of Win function Readfile
  Front: ^Byte;
  Back: ^Byte;
  Temp: Byte;
  I : Integer;
  Width, Height : Integer;
  pData : Pointer;

  // used for loading from resource
  ResStream : TResourceStream;
begin

[.....................]
    BitmapFile := CreateFile(PChar(Filename), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0);
    if (BitmapFile = INVALID_HANDLE_VALUE) then begin
      MessageBox(0, PChar('Error opening ' + Filename), PChar('BMP Unit'), MB_OK);
      Exit;
    end;

    // Get header information
    ReadFile(BitmapFile, FileHeader, SizeOf(FileHeader), ReadBytes, nil);
    ReadFile(BitmapFile, InfoHeader, SizeOf(InfoHeader), ReadBytes, nil);

    // Get palette
    PaletteLength := InfoHeader.biClrUsed;
    //SetLength(Palette, PaletteLength); commented by fabrizio ( i don't know how to solve !!)
    ReadFile(BitmapFile, Palette, PaletteLength, ReadBytes, nil);
    if (ReadBytes <> PaletteLength) then begin
      MessageBox(0, PChar('Error reading palette'), PChar('BMP Unit'), MB_OK);
      Exit;
    end;

    Width := InfoHeader.biWidth;
    Height := InfoHeader.biHeight;
    BitmapLength := InfoHeader.biSizeImage;
    if BitmapLength = 0 then
      BitmapLength := Width * Height * InfoHeader.biBitCount Div 8;

    // Get the actual pixel data
    GetMem(pData, BitmapLength);
    ReadFile(BitmapFile, pData^, BitmapLength, ReadBytes, nil);
    if (ReadBytes <> BitmapLength) then begin
      MessageBox(0, PChar('Error reading bitmap data'), PChar('BMP Unit'), MB_OK);
      Exit;
    end;
    CloseHandle(BitmapFile);
  end;

  // Bitmaps are stored BGR and not RGB, so swap the R and B bytes.
  for I :=0 to Width * Height - 1 do
  begin
    Front := Pointer(Integer(pData) + I*3);
    Back := Pointer(Integer(pData) + I*3 + 2);
    Temp := Front^;
    Front^ := Back^;
    Back^ := Temp;
  end;
Hier mal der relevante Code der laden-funktion.
Björn Zeutzheim
Codename: Performancepumpe
  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:29 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 by Thomas Breitkreuz