Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi loch im stream (https://www.delphipraxis.net/46672-loch-im-stream.html)

DGL-luke 29. Mai 2005 16:54


loch im stream
 
ich hab ein leck in einem tmemorystream:

Delphi-Quellcode:
procedure TForm1.Compress(quality:integer;source:TBitmap32;BTarget:TBitMap32);
var image:TImage;
    stream:TStream;
begin
stream:=TMemorystream.Create;

application.MessageBox('memorystream erstellt','');

Originalleft.SaveToStream(stream); //originalleft(TImage32) enthält 100% ein bitmap;
Originalleft.SaveToFile('C:\kompressor_test_orig.bmp');  //hier kommt etwas an !!!!!!!!!

image:=TImage.Create(nil);
image.Picture.Bitmap.LoadFromStream(stream);

image.Picture.Bitmap.SaveToFile('C:\kompressor_test_bitmap.bmp'); //hier nicht -> 0 byte file !!!!!!!!!!!

application.MessageBox('source->image abgeschlossen','');

//ab hier unwichtig....

jpeg.Assign(image.Picture.bitmap);
//application.MessageBox('jpeg beladen hat funktioniert!','2');
JPEG.CompressionQuality:=quality;
//application.MessageBox('qualität zuweisen hat funktioniert!','3');
JPEG.Compress;
//application.MessageBox('komprimieren hat funktioniert!','4');
JPEG.SaveToStream(jpgstream);

//application.MessageBox('jpeg speichern hat funktioniert!','5');
BTarget.LoadFromStream(jpgstream);

OriginalRight.LoadFromstream(jpgstream);

self.ILeftMouseMove(IRight,[],0,0,nil);

Image.Free;
stream.Free;
end;
die mit ausrufezeichen versehenen kommentare beschreiben mein problem ganz gut....

was ist die lösung?

muss ich irgendwie noch mit dem stream was machen? write aufrufen?

xaromz 29. Mai 2005 17:02

Re: loch im stream
 
Hallo,

setz doch vor dem

Delphi-Quellcode:
image.Picture.Bitmap.LoadFromStream(stream);
mal ein
Delphi-Quellcode:
stream.Position := 0;
Gruß
xaromz

jfheins 29. Mai 2005 17:07

Re: loch im stream
 
Versuche doch, das Bitmap zu assign-en, denn ich glaube, TBitmap32 und TBitmap sind so nicht kompatibel ...

DGL-luke 29. Mai 2005 17:12

Re: loch im stream
 
@xaromz: werd ich versuchen, kann mir aber nicht vorstellen ,dass es hilft.

@jfheins: da ein TImage32 IMMER als bitmap abspeichert, muss es als stream gehen. assign gibt mir auf jeden fall den wohlbekannten fehler "TBitmap32 kann nicht zu TBitmap zugewiesen werden..."

EDIT: da hol mich doch der teufel, das geht tatsächlich, xaromz.....


Alle Zeitangaben in WEZ +1. Es ist jetzt 01:47 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