 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Gary Mrenak Guest
|
Posted: Tue Jul 29, 2003 9:13 pm Post subject: TImage and JPGs |
|
|
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
|
Posted: Tue Jul 29, 2003 10:41 pm Post subject: Re: TImage and JPGs |
|
|
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
|
Posted: Wed Jul 30, 2003 6:12 pm Post subject: Re: TImage and JPGs |
|
|
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 |
|
 |
|
|
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
|
|