Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread How to read dbisam blob fieds?
Sat, Apr 12 2008 12:36 AMPermanent Link

"Halim Boumedjirek"
I am trying to read my DBISAM blob field which is an image and load it into
an image list component. I am using the following code:

Var LStream: TStream;
 iCon1: Ticon;
 Begin
   ImageList1.Clear;
   Lstream
:=ButtonTbl.CreateBlobStream(ButtonTbl.fieldbyName('ButtonIcon'), bmRead);
// this is always giving me an empty stream
   Icon1.LoadFromStream(Lstream);
   Imagelist1.InsertIcon(0, Icon1);

etc..
This line is always returning an empty stream.  Lstream
:=ButtonTbl.CreateBlobStream(ButtonTbl.fieldbyName('ButtonIcon'), bmRead);
is this the correct synthax?
Thank you,
-Halim

Sat, Apr 12 2008 10:01 AMPermanent Link

"Walter Matte"
This is one way I have handles Blobs - Streams...

var
 rStream : TMemoryStream;

 rStream := TMemoryStream.Create;
 try
   TBlobField(dm1.tbLE.FieldByName('LetterBody')).SaveToStream(rStream);
   rStream.Position := 0;  // reset to start of stream....
   ppLetter.LoadFromRTFStream(rStream);
 finally
   rStream.Free;
 end;


........  this should do it.... (untested...)

(Don't you need to Create TIcon?)

LStream := TStream.Create;
try
 TBlobField(ButtonTbl.FieldByName('ButtonIcon').SaveToStream(LStream);
 LStream.Postion := 0;
 Icon1.LoadFromStream(Lstream);
finally
 LStream.Free;
end;


Walter

"Halim Boumedjirek" <Hboumedjirek@idealss.com> wrote in message
news:25438244-4195-427E-BFE3-C8935A652A92@news.elevatesoft.com...
>I am trying to read my DBISAM blob field which is an image and load it into
>an image list component. I am using the following code:
>
> Var LStream: TStream;
>  iCon1: Ticon;
>  Begin
>    ImageList1.Clear;
>    Lstream
> :=ButtonTbl.CreateBlobStream(ButtonTbl.fieldbyName('ButtonIcon'), bmRead);
> // this is always giving me an empty stream
>    Icon1.LoadFromStream(Lstream);
>    Imagelist1.InsertIcon(0, Icon1);
>
> etc..
> This line is always returning an empty stream.  Lstream
> :=ButtonTbl.CreateBlobStream(ButtonTbl.fieldbyName('ButtonIcon'), bmRead);
> is this the correct synthax?
> Thank you,
> -Halim
>

Sat, Apr 12 2008 6:21 PMPermanent Link

"Halim Boumedjirek"
Yes creating the icon is necessary but still it does not work, I get the
message: icon image is not valid. I think the stream was still empty.
I used:

var LStream: TMemoryStream;

LStream := TMemoryStream.Create;
Icon1:=TIcon.Create;
try
 TBlobField(ButtonFrame1.ButtonTbl.FieldByName('ButtonIcon')).SaveToStream(LStream);
 LStream.Position := 0;
 Icon1.LoadFromStream(Lstream);
finally
 LStream.Free;
Icon1.free
end;


Thank you for your help,
-Halim




"Walter Matte" <mattew_@_interlog.com> wrote in message
news:48CE7C83-518E-41BD-8DE0-C600F6BD1AED@news.elevatesoft.com...
> This is one way I have handles Blobs - Streams...
>
> var
>  rStream : TMemoryStream;
>
>  rStream := TMemoryStream.Create;
>  try
>    TBlobField(dm1.tbLE.FieldByName('LetterBody')).SaveToStream(rStream);
>    rStream.Position := 0;  // reset to start of stream....
>    ppLetter.LoadFromRTFStream(rStream);
>  finally
>    rStream.Free;
>  end;
>
>
> .......  this should do it.... (untested...)
>
> (Don't you need to Create TIcon?)
>
> LStream := TStream.Create;
> try
>  TBlobField(ButtonTbl.FieldByName('ButtonIcon').SaveToStream(LStream);
>  LStream.Postion := 0;
>  Icon1.LoadFromStream(Lstream);
> finally
>  LStream.Free;
> end;
>
>
> Walter
>
> "Halim Boumedjirek" <Hboumedjirek@idealss.com> wrote in message
> news:25438244-4195-427E-BFE3-C8935A652A92@news.elevatesoft.com...
>>I am trying to read my DBISAM blob field which is an image and load it
>>into an image list component. I am using the following code:
>>
>> Var LStream: TStream;
>>  iCon1: Ticon;
>>  Begin
>>    ImageList1.Clear;
>>    Lstream
>> :=ButtonTbl.CreateBlobStream(ButtonTbl.fieldbyName('ButtonIcon'),
>> bmRead); // this is always giving me an empty stream
>>    Icon1.LoadFromStream(Lstream);
>>    Imagelist1.InsertIcon(0, Icon1);
>>
>> etc..
>> This line is always returning an empty stream.  Lstream
>> :=ButtonTbl.CreateBlobStream(ButtonTbl.fieldbyName('ButtonIcon'),
>> bmRead);
>> is this the correct synthax?
>> Thank you,
>> -Halim
>>
>
>

Sun, Apr 13 2008 4:14 AMPermanent Link

Dan Rootham [Team Elevate]
Halim,

<< Yes creating the icon is necessary but still it does not work >>

Maybe you need to declare and create a TBlobField variable too?

The example below is based on a working piece of code from one of
my applications to convert a blob to a widestring (not load an icon).

But I think that the principle is the same. Try it and see if this
helps.

Regards,
Dan Rootham [Team Elevate]


untested:

procedure TForm1.LoadIcon;
var
 MyBlob: TBlobField;
 MemStream: TMemoryStream;
 Icon1: TIcon;
begin
 MyBlob := TBlobField(ButtonFrame1.ButtonTbl.FieldByName('ButtonIcon')
 Icon1:=TIcon.Create;
 LStream := TMemoryStream.Create;

 try
   if (MyBlob.BlobSize > 0) then
   begin
     MyBlob.SaveToStream(LStream);
     LStream.Position := 0;
     Icon1.LoadFromStream(Lstream);
 finally
   LStream.Free;
   Icon1.free
 end;
end;
Sun, Apr 13 2008 8:40 AMPermanent Link

"Walter Matte"
I'm sure this code and Dan's will work.

Is the graphic compatible with button?

Walter


"Halim Boumedjirek" <Hboumedjirek@idealss.com> wrote in message
news:CB74A2C8-233A-45CC-8FD7-5B22AF947406@news.elevatesoft.com...
> Yes creating the icon is necessary but still it does not work, I get the
> message: icon image is not valid. I think the stream was still empty.
> I used:
>
> var LStream: TMemoryStream;
>
> LStream := TMemoryStream.Create;
> Icon1:=TIcon.Create;
> try
>
> TBlobField(ButtonFrame1.ButtonTbl.FieldByName('ButtonIcon')).SaveToStream(LStream);
>  LStream.Position := 0;
>  Icon1.LoadFromStream(Lstream);
> finally
>  LStream.Free;
> Icon1.free
> end;
>
>
> Thank you for your help,
> -Halim
>
>
>
>
> "Walter Matte" <mattew_@_interlog.com> wrote in message
> news:48CE7C83-518E-41BD-8DE0-C600F6BD1AED@news.elevatesoft.com...
>> This is one way I have handles Blobs - Streams...
>>
>> var
>>  rStream : TMemoryStream;
>>
>>  rStream := TMemoryStream.Create;
>>  try
>>    TBlobField(dm1.tbLE.FieldByName('LetterBody')).SaveToStream(rStream);
>>    rStream.Position := 0;  // reset to start of stream....
>>    ppLetter.LoadFromRTFStream(rStream);
>>  finally
>>    rStream.Free;
>>  end;
>>
>>
>> .......  this should do it.... (untested...)
>>
>> (Don't you need to Create TIcon?)
>>
>> LStream := TStream.Create;
>> try
>>  TBlobField(ButtonTbl.FieldByName('ButtonIcon').SaveToStream(LStream);
>>  LStream.Postion := 0;
>>  Icon1.LoadFromStream(Lstream);
>> finally
>>  LStream.Free;
>> end;
>>
>>
>> Walter
>>
>> "Halim Boumedjirek" <Hboumedjirek@idealss.com> wrote in message
>> news:25438244-4195-427E-BFE3-C8935A652A92@news.elevatesoft.com...
>>>I am trying to read my DBISAM blob field which is an image and load it
>>>into an image list component. I am using the following code:
>>>
>>> Var LStream: TStream;
>>>  iCon1: Ticon;
>>>  Begin
>>>    ImageList1.Clear;
>>>    Lstream
>>> :=ButtonTbl.CreateBlobStream(ButtonTbl.fieldbyName('ButtonIcon'),
>>> bmRead); // this is always giving me an empty stream
>>>    Icon1.LoadFromStream(Lstream);
>>>    Imagelist1.InsertIcon(0, Icon1);
>>>
>>> etc..
>>> This line is always returning an empty stream.  Lstream
>>> :=ButtonTbl.CreateBlobStream(ButtonTbl.fieldbyName('ButtonIcon'),
>>> bmRead);
>>> is this the correct synthax?
>>> Thank you,
>>> -Halim
>>>
>>
>>
>
>

Sun, Apr 13 2008 4:55 PMPermanent Link

"Halim Boumedjirek"
I ended up using something else. I used a tpicture then resized it to look
like an icone using a tbitmap.
see below,

 try
   try
     LStream := TMemoryStream.Create;
     TBlobField(ButtonFrame1.ButtonTbl.FieldByName('ButtonIcon')).SaveToStream(LStream);
     LStream.Position := 0;
     image1.Picture.Bitmap.LoadFromStream(Lstream); ;
    {
     To modify the appearance of the image, you need to use TCanvas to draw
a
smaller image. Create a new TBitmap object, set its dimensions, and then
use the Canvas.StretchDraw method to draw the original image onto the
new one. Add the new object to the image list.
     }
     Rect1.Left := 0;
     Rect1.Top := 0;
     Rect1.Right := 32;
     Rect1.Bottom := 32;
     MyBMP := TBitmap.Create;
     MyBMP.Width := 32;
     MyBMP.Height := 32;
     MyBMP.Canvas.StretchDraw(Rect1, image1.Picture.Bitmap);
     imagelist1.InsertMasked(Grid1.RowCount - 2, myBMP,
myBMP.TransparentColor);
   finally
     LStream.Free;
   end;
 except
   on e: exception do showmessage(e.Message);
 end;




"Walter Matte" <mattew_@_interlog.com> wrote in message
news:F0C8CB86-9B40-41B5-87E0-ADE8CB4A819F@news.elevatesoft.com...
> I'm sure this code and Dan's will work.
>
> Is the graphic compatible with button?
>
> Walter
>
>
> "Halim Boumedjirek" <Hboumedjirek@idealss.com> wrote in message
> news:CB74A2C8-233A-45CC-8FD7-5B22AF947406@news.elevatesoft.com...
>> Yes creating the icon is necessary but still it does not work, I get the
>> message: icon image is not valid. I think the stream was still empty.
>> I used:
>>
>> var LStream: TMemoryStream;
>>
>> LStream := TMemoryStream.Create;
>> Icon1:=TIcon.Create;
>> try
>>
>> TBlobField(ButtonFrame1.ButtonTbl.FieldByName('ButtonIcon')).SaveToStream(LStream);
>>  LStream.Position := 0;
>>  Icon1.LoadFromStream(Lstream);
>> finally
>>  LStream.Free;
>> Icon1.free
>> end;
>>
>>
>> Thank you for your help,
>> -Halim
>>
>>
>>
>>
>> "Walter Matte" <mattew_@_interlog.com> wrote in message
>> news:48CE7C83-518E-41BD-8DE0-C600F6BD1AED@news.elevatesoft.com...
>>> This is one way I have handles Blobs - Streams...
>>>
>>> var
>>>  rStream : TMemoryStream;
>>>
>>>  rStream := TMemoryStream.Create;
>>>  try
>>>    TBlobField(dm1.tbLE.FieldByName('LetterBody')).SaveToStream(rStream);
>>>    rStream.Position := 0;  // reset to start of stream....
>>>    ppLetter.LoadFromRTFStream(rStream);
>>>  finally
>>>    rStream.Free;
>>>  end;
>>>
>>>
>>> .......  this should do it.... (untested...)
>>>
>>> (Don't you need to Create TIcon?)
>>>
>>> LStream := TStream.Create;
>>> try
>>>  TBlobField(ButtonTbl.FieldByName('ButtonIcon').SaveToStream(LStream);
>>>  LStream.Postion := 0;
>>>  Icon1.LoadFromStream(Lstream);
>>> finally
>>>  LStream.Free;
>>> end;
>>>
>>>
>>> Walter
>>>
>>> "Halim Boumedjirek" <Hboumedjirek@idealss.com> wrote in message
>>> news:25438244-4195-427E-BFE3-C8935A652A92@news.elevatesoft.com...
>>>>I am trying to read my DBISAM blob field which is an image and load it
>>>>into an image list component. I am using the following code:
>>>>
>>>> Var LStream: TStream;
>>>>  iCon1: Ticon;
>>>>  Begin
>>>>    ImageList1.Clear;
>>>>    Lstream
>>>> :=ButtonTbl.CreateBlobStream(ButtonTbl.fieldbyName('ButtonIcon'),
>>>> bmRead); // this is always giving me an empty stream
>>>>    Icon1.LoadFromStream(Lstream);
>>>>    Imagelist1.InsertIcon(0, Icon1);
>>>>
>>>> etc..
>>>> This line is always returning an empty stream.  Lstream
>>>> :=ButtonTbl.CreateBlobStream(ButtonTbl.fieldbyName('ButtonIcon'),
>>>> bmRead);
>>>> is this the correct synthax?
>>>> Thank you,
>>>> -Halim
>>>>
>>>
>>>
>>
>>
>
>

Mon, Apr 14 2008 3:34 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Halim,

It shouldn't be necessary to save the BLOB stream to another stream before
loading the stream into the bitmap.  You should be able to load the BLOB
stream directly.   Is the dataset in edit or insert mode while you're
executing this code ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Apr 16 2008 3:37 PMPermanent Link

"Halim Boumedjirek"
No, the dataset is not in edit or insert mode but yes I see what you mean.
Thank you,
-Halim
"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message
news:C99D74DC-B2F9-4140-B470-3C4B20047226@news.elevatesoft.com...
> Halim,
>
> It shouldn't be necessary to save the BLOB stream to another stream before
> loading the stream into the bitmap.  You should be able to load the BLOB
> stream directly.   Is the dataset in edit or insert mode while you're
> executing this code ?
>
> --
> Tim Young
> Elevate Software
> www.elevatesoft.com
>

Image