Board index » delphi » Loading jpg's into a paradox7 blob field

Loading jpg's into a paradox7 blob field

Hi,

I Use this code to load bitmaps into a blob field

begin;
if Openpicturedialog1.Execute then
if OpenPictureDialog1.Filename <> NULL then
begin
table1.edit;
if TBLOBField(Table1.Fields[0]) <> nil then table1.append;
TBLOBField(Table1.Fields[0]).LoadFromFile(Openpicturedialog1.Filename);
Table1.append;
end;

Now I would like to do the same with jpg's and gif's.
Any ideas?

thanks

 

Re:Loading jpg's into a paradox7 blob field


Quote
>martin wrote:

> Now I would like to do the same with jpg's and gif's.
> Any ideas?

You can uncomplicate your code a bit:

if Openpicturedialog1.Execute then begin
 Table1.Append;
 (Table1.Fields[0] as TBLOBField).LoadFromFile(Op..1.Filename);
 Table1.Post
end;

Do the same for any image type. However, to display the images DBImage
is suited only for BMPs. For JPEGs, GIFs etc. you need a TImage which
you load via a MemoryStream.
________
Andreas
Delphi 5.01 Pro, NT4.0 Sp5
Direct replies mailto:p...@augsburg.netsurf.de

Re:Loading jpg's into a paradox7 blob field


Hi,

thanks for your help.
Is the only method to write jpg and gif files to a blob field that of a
Memory Stream?
If so, what's the syntaxis for it?
I've read that a graphic field can only contain bmp files so I've changed it
to Binary field type.

thanks

<SNIP>

Quote
> You can uncomplicate your code a bit:

> if Openpicturedialog1.Execute then begin
>  Table1.Append;
>  (Table1.Fields[0] as TBLOBField).LoadFromFile(Op..1.Filename);
>  Table1.Post
> end;

> Do the same for any image type. However, to display the images DBImage
> is suited only for BMPs. For JPEGs, GIFs etc. you need a TImage which
> you load via a MemoryStream.

<SNIP>

Re:Loading jpg's into a paradox7 blob field


Quote
>martin wrote:

>Is the only method to write jpg and gif files to a blob field that of  >Memory Stream?

As I already said, writing to is not the problem, a BinaryField can
store any data. You use a MemoryStream to get them from the table for
display in a TImage.
________
Andreas
Delphi 5.01 Pro, NT4.0 Sp5
Direct replies mailto:p...@augsburg.netsurf.de

Re:Loading jpg's into a paradox7 blob field


Andreas,

You can load ANYTHING into a blob field that previously resided in a file,
whether it is a .jpg, .gif, a .exe, or an encrypted document describing
your mother's knickers.

You load into a blob field by first creating a TFileStream, and then use
the blob field's LoadFromStream method.

Displaying a picture is another issue completely.  First, let's throw
TDBImage out the window completely, because it will only support bitmaps.
Now, if you use the stock TImage that comes with D5, you can display
jpegs.  You can get Anders Melanders EXCELLENT gif component for free, and
your TImage will do gifs, animated gifs, and more.  There are other thrid
party products which permit other file formats to be displayed.

To get an image from the blob field to the TImage, you first create a
memory stream.  Then you use the blob field's SaveToStream method to get
the blob into the stream.  Finally, you use the TImage (or other component)
LoadFromStream method to get the image into the TImage for display.

Quote
martin wrote:
> Hi,

> I Use this code to load bitmaps into a blob field

> begin;
> if Openpicturedialog1.Execute then
> if OpenPictureDialog1.Filename <> NULL then
> begin
> table1.edit;
> if TBLOBField(Table1.Fields[0]) <> nil then table1.append;
> TBLOBField(Table1.Fields[0]).LoadFromFile(Openpicturedialog1.Filename);
> Table1.append;
> end;

> Now I would like to do the same with jpg's and gif's.
> Any ideas?

> thanks

Re:Loading jpg's into a paradox7 blob field


Quote
> or an encrypted document describing your mother's knickers.

Have you checked on max BlobField size. My mother was a very large
lady!

Other Threads