Autor Beitrag
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Sa 12.11.05 21:08 
Hallo Leute!

Ich habe wegen dieser Frage schon im Forum gesucht und es scheint so, als ob der Fehler garnicht existieren dürfte, weil alle Codeschnipsel die ich gesehen habe das gleiche machen wie ich.
Also: Ich habe ein TJPEGImage und möchte es nun via Prozedur in eine per Pointer übergebene TBitmap schreiben. Dazu nutze ich folgenden Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type
  PBitmap = ^Graphics.TBitmap;

procedure GetBitmap(Destination: PBitmap);
var
  JPEGImage: TJPEGImage;
begin
  // ... blabla JPEG laden

  Destination^.Assign(JPEGImage);
end

Dann kommt die Exception
Zitat:
EConvertError "Cannot assign a TJPEGImage to a TBitmap"


Warum? Wie bekomme ich es hin, dass ich das Bild aus dem JPEGImage in eine TBitmap reinbekomme?

thx
Alstar
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: So 13.11.05 11:19 
Erstmal eine Frage vorweg: Warum PBitmap? Hätte es ein simples TBitmap nicht auch getan?

Zu deinem Problem:

ausblenden Delphi-Quelltext
1:
2:
3:
Destination.Width := JPEG.Width;
Destination.Height := JPEG.Height;
Destination.Canvas.Draw(0,0,JPEG);


Ungetestet, müsste aber funzen.

_________________
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.
Alstar Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: So 13.11.05 13:13 
Hallo!
Danke das funzt wenigstens! Aber funktioniert das andere nicht?
Ich mache es mit Pointern, da ich diese Funktionen in eine Ressourcen-DLL ausgelagert hab und ein Arbeiten mit Pointern dann sehr viel Speicherschonender ist.

Alstar
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: So 13.11.05 13:56 
Aso, du nutzt eine DLL ;-) Dann ist das klar, das es nicht geht ;-) TJPegImage <> TJPEGImage :P

In DLLs existiert eine zweite Implementation von TJPEGImage, die sich von der der Hauptanwendung durch den Zeiger auf die Typ-Info unterscheided. Wenn Du Klassen in der DLL instantiieren möchtest übergib Dir den Zeiger auf die Funktion FindClass und instantiier damit die Klassen.

Die andere Möglichkeit ist, Packages für deine Ressourcen-DLLs zu nutzen. Das laden dieser erfolgt dann mit LoadPackage. Gibt's ein Beispiel auch hier im DF.

_________________
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.