BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TImage and JPGs

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Gary Mrenak
Guest





PostPosted: Tue Jul 29, 2003 9:13 pm    Post subject: TImage and JPGs Reply with quote



D7, Win2k.
I'm trying to use a tImage component to display bitmaps or jpgs. The bitmaps
can be loaded using either timagename.picture or timagename.picture.graphic,
but jpgs produce an error (expects a bitmap) when I try to assign a
timagename.Picture.graphic to a tpersistent. If I want to be able to load
and display either a bmp or jpg into the same timage object, how is that
done?

Thanks.


Back to top
Peter Haas
Guest





PostPosted: Tue Jul 29, 2003 10:41 pm    Post subject: Re: TImage and JPGs Reply with quote



Hi Gary,

Gary Mrenak wrote in <3f26e497$1 (AT) newsgroups (DOT) borland.com>:
Quote:
D7, Win2k.
I'm trying to use a tImage component to display bitmaps or jpgs.

uses
..., JPEG, ...;

Bye Peter.
--
Why should we be interested is someone who considers us a waste basket?
Robert Marquardt (Team JEDI) in <b4mf4g$u0k$1 (AT) talkto (DOT) net> to me
regarding JEDI's disinterest on my contribution attempts.
Maybe JEDI users have more interest: http://jediplus.pjh2.de/index.php

Back to top
Gary Mrenak
Guest





PostPosted: Wed Jul 30, 2003 6:12 pm    Post subject: Re: TImage and JPGs Reply with quote



Very helpful response! Thanks!

I'll get right on your suggestions.

Gary

"Peter Haas" <newsgroupfeedback (AT) pjh2 (DOT) de> wrote

Quote:
Hi Gary,

Gary Mrenak wrote in <3f27c355$1 (AT) newsgroups (DOT) borland.com>:
If I can read in and display a jpg, how can I assign it to a tPersistent
object defined on a blob database field?

TPersistent is a abstract class, this do mean, that you can not use this
class, you need a class, which is derived from TPersistent.

To store a JPEG in a blob database field you must save it per stream,
e.g. (untested, written directly to the posting):

procedure SaveJpegToBlobField(Jpg: TJpegImage; BlobField: TBlobField);
var
Stream: TMemoryStream;
begin
Stream := TMemoryStream.Create;
try
Jpg.SaveToStream(Stream);
BlobField.LoadFromStream(Stream);
finally
Stream.Free;
end;
end;

The method TBlobField.Assign need to use a TJpegImage descendant, which
support Assign to a TBlobField:

type
TJpegImageBlob = class(TJpegImage)
protected
procedure AssignTo(Dest: TPersistent); override;
end;

procedure TJPEGImageBlob.AssignTo(Dest: TPersistent);
var
Stream: TMemoryStream;
begin
if Dest is TBlobField then
begin
Stream := TMemoryStream.Create;
try
SaveToStream(Stream);
TBlobField(Dest).LoadFromStream(Stream);
finally
Stream.Free;
end;
end
else
inherited AssignTo(Dest);
end;

Bye Peter.

p.s. Please optimize your quoting, read
http://info.borland.com/newsgroups/netiquette.html
--
Why should we be interested is someone who considers us a waste basket?
Robert Marquardt (Team JEDI) in <b4mf4g$u0k$1 (AT) talkto (DOT) net> to me
regarding JEDI's disinterest on my contribution attempts.
Maybe JEDI users have more interest: http://jediplus.pjh2.de/index.php




Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.