Board index » delphi » Store JPG image in paradox Graphic field

Store JPG image in paradox Graphic field

I have a Paradox table that contains an image field of type Graphic.  My
vendor has supplied me w/ a list of JPG images of my product line.  How do i
assign the JPG graphic to the image field in the table?

Regards,
Scott

 

Re:Store JPG image in paradox Graphic field


Quote
"Scott" <scott.dan...@4pmsolutions.com> wrote in message

news:3aa5652f_2@dnews...

Quote
> I have a Paradox table that contains an image field of type Graphic.  My
> vendor has supplied me w/ a list of JPG images of my product line.  How do
i
> assign the JPG graphic to the image field in the table?

TRY
  Try John Herbster's JPEG/BLOB example hat stores images from JPEG files
into Paradox table BLOB field.

http://homepages.borland.com/efg2lab/Library/Delphi/Graphics/JohnHerb...
Jpeg_1%2019991207.zip
FINALLY
  good luck
END

--
efg     e...@efg2.com     Earl F. Glynn, Overland Park, KS  USA

efg's Computer Lab:  http://www.efg2.com/Lab
Mirror:  http://homepages.borland.com/efg2lab/Default.htm

Re:Store JPG image in paradox Graphic field


I found the example but the link
http://homepages.borland.com/efg2lab/Library/Delphi/Graphics/JohnHerb...
 does not work.  I found the example at
http://homepages.borland.com/efg2lab/Library/Delphi/Graphics/FileForm...
onversion.htm#Conversions and scroll down to file format "Blob".

Regards,
Scott

Earl F. Glynn <EarlGl...@att.net> wrote in message news:3aa57688_1@dnews...

Quote
> "Scott" <scott.dan...@4pmsolutions.com> wrote in message
> news:3aa5652f_2@dnews...
> > I have a Paradox table that contains an image field of type Graphic.  My
> > vendor has supplied me w/ a list of JPG images of my product line.  How
do
> i
> > assign the JPG graphic to the image field in the table?

> TRY
>   Try John Herbster's JPEG/BLOB example hat stores images from JPEG files
> into Paradox table BLOB field.

http://homepages.borland.com/efg2lab/Library/Delphi/Graphics/JohnHerb...
Quote
> Jpeg_1%2019991207.zip
> FINALLY
>   good luck
> END

> --
> efg     e...@efg2.com     Earl F. Glynn, Overland Park, KS  USA

> efg's Computer Lab:  http://www.efg2.com/Lab
> Mirror:  http://homepages.borland.com/efg2lab/Default.htm

Re:Store JPG image in paradox Graphic field


Quote
Scott <scott.dan...@4pmsolutions.com> wrote in message 3aa5652f_2@dnews...
> I have a Paradox table that contains an image field of type Graphic.  My
> vendor has supplied me w/ a list of JPG images of my product line.  How do
i
> assign the JPG graphic to the image field in the table?

> Regards,
> Scott

Only tBlobfield type can store jpg in a table : the tgraphicfield is for
tbitmap format .

Re:Store JPG image in paradox Graphic field


Hi Scott,

Here's how I did something like this .. loading JPG's and saving to Blob
field (Delphi 3)
Perhaps not the best, but works ..
Requires the use of  jpeg unit, supplied with D3

Hope this helps,

Graeme
-----------------------------------------------
:
:
      // check if the image is a JPG
      if (AnsiUpperCase(ExtractFileExt(AFileName)) = '.JPG') then
      begin
        try
          AImage := nil;
          AMemStream := nil;
          try
            // create a few things we'll need to grab the JPG
            AImage := TImage.Create(self);;
            ABitmap := TBitmap.Create;
            AMemStream := TMemoryStream.Create;
            // load the JPG into the TImage
            AImage.Picture.LoadFromFile(AFileName);
            // copy the TImage -> TBitmap
            CopyImageToBitmap(AImage, ABitmap);
            // save the bitmap to a memory stream
            ABitmap.SaveToStream(AMemStream);
            // finally, load the bitmap from the memory stream to the Blob
field

TBlobField(FDataTable.FieldByName('IMAGE')).LoadFromStream(AMemStream);
          finally
            AMemStream.Free;
            ABitmap.Free;
            AImage.Free;
          end;
        except
          raise Exception.Create('Error reading image: ' + AFileName);
        end;
      end else
      // BMP? Load the image into the blob field direct from disk
        TBlobField(FDataTable.FieldByName('IMAGE')).LoadFromFile(AFileName);
      // save the image's directory path for next time
:
:
-----------------------------------------------
** CopyImageToBitmap **

:
:
  try
    // see if we have a valid bitmap, if not, create it!
    if (ABitmap = nil)then
    try
      ABitmap := TBitmap.Create;
      ABitmap.PixelFormat := pfDevice;
    except
      Result := False;
    end;
    ABitmap.Width  := AImage.Picture.Width;
    ABitmap.Height := AImage.Picture.Height;
    // draw onto the bitmap canvas
    if (AImage.Picture.Graphic is TJPEGImage) then
      ABitmap.Canvas.Draw(0, 0, AImage.Picture.Graphic) // it's a JPG
    else
      ABitmap.Canvas.Draw(0, 0, AImage.Picture.Bitmap); // it's a BMP
    Result := True;
  except
:
:

Quote
Scott <scott.dan...@4pmsolutions.com> wrote in message

news:3aa5652f_2@dnews...
Quote
> I have a Paradox table that contains an image field of type Graphic.  My
> vendor has supplied me w/ a list of JPG images of my product line.  How do
i
> assign the JPG graphic to the image field in the table?

> Regards,
> Scott

Other Threads