BackImage Stream and clear

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
mivchart
Newbie
Newbie
Posts: 31
Joined: Thu Dec 04, 2008 12:00 am

BackImage Stream and clear

Post by mivchart » Thu Feb 24, 2011 8:33 am

Hello

D2007 and TeeTree VCL 8.04

I load BackImage from Stream, it's Ok that good result with under methode


function LoadBackImageFromStream:Boolean;
Var i:integer;
jpg: TJPEGImage;
Stream1:TMemoryStream;
begin
try
Stream1:=TMemoryStream.Create;
jpg:=TJPEGImage.Create;
try
Stream1:=GetStreamImageFromSever; //Load Stream from my server by Webservice > it's Ok
if Stream1.size>=0 then
jpg.LoadFromStream(Stream1);
Tree1.BackImage.Assign(jpg);

finally
FreeAndNil(jpg);
FreeAndNil(Stream1);
end;
except
//managment error
end;
end;



Q1) do hou have other solution for direct load image by stream, without TJPEGImage and without file disk?

Q2) How do take for clear Image if my stream is empty or bad ?

Q3) do you have best practice and géneral méthode for image (jpeg,bmp,Gif etc) without file disk ?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: BackImage Stream and clear

Post by Narcís » Thu Feb 24, 2011 11:29 am

Hi mivchart,

I think those are Delphi generic issues. I'll give my 2 cents. though.
Q1) do hou have other solution for direct load image by stream, without TJPEGImage and without file disk?
You could use TBitmap as in the code snippet below.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var Bitmap: TBitmap;
    Stream: TMemoryStream;
begin
  Bitmap:=Bitmap.Create;
  Stream:=TMemoryStream.Create;
  //Load your image to the stream here.

  if Assigned(Stream) then
  begin
    Stream.Position:=0;
    Bitmap.LoadFromStream(Stream);
  end;
end;
Q2) How do take for clear Image if my stream is empty or bad ?
Use Assigned as in the code snippet above.
Q3) do you have best practice and géneral méthode for image (jpeg,bmp,Gif etc) without file disk ?
I don't know if this is best practice but I'd try doing something as in the code example I posted.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

mivchart
Newbie
Newbie
Posts: 31
Joined: Thu Dec 04, 2008 12:00 am

Re: BackImage Stream and clear

Post by mivchart » Thu Feb 24, 2011 1:47 pm

OK,

But if my Stream used for several type (Jpeg, Gif, Bmp, etc), for each i need déclare spécial grapic type ??

Yeray
Site Admin
Site Admin
Posts: 9622
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: BackImage Stream and clear

Post by Yeray » Fri Feb 25, 2011 3:17 pm

Hi mivchart,

You could try with TOleGraphic as in the example here.
Also, if you are source code customer, feel free to look into TeeChart sources to see how the different types are treated.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply