Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

question about 3rd party component 1

Status
Not open for further replies.

kyriakos70

Programmer
Jul 24, 2008
87
GR
Hello,
I have a question about a component named vintasofttwain activex, my question is how can I aquire an image and save it as jpg. Any help anyone who uses it.

Thank you
Kyriakos
 
here is the code

if Image1.Picture.Bitmap.Handle <> 0 then Image1.Picture.Bitmap.ReleaseHandle;
Image1.Picture.Bitmap.Handle := VSTwain1.GetCurrentImageAsHBitmap;

I want to save the current image as jpg in the sql table, how can I do it?

Kyriakos

 
Googling "Delphi save jpg to blob" yielded this experts-exchange post:
Code:
var
  sFileName: string;
  tblImage: TADOTable;
  imgCover: TJPEGImage;
begin
  // first get the image if it exists
  sFileName := Trim( edtPicture.Text) + '.jpg';
  if FileExists( sFileName) then
  begin
    imgCover := TJPEGImage.Create;
    try
      // load the current image
      imgCover.LoadFromFile( sFileName);
      // next load the cover image to the database temporarily
      tblImage := TADOTable.Create( nil);
      try
        with tblImage do
        begin
          // create the ADO Table, set the connection and the table name
          ConnectionString := 'SOMECONNECTIONSTRING';
          TableName  := 'YOURTABLE';
          // open the table and append a new record
          Open;
          Append;
          // add the values for the new record
          FieldByName( 'PictureName').AsString := 'PictureName';
          FieldByName( 'FilePath').AsString := sFileName;
          FieldByName( 'YourImage').Assign( imgCover);
          // post the data
          Post;
        end;
      finally
        // free up the table
        FreeAndNil( tblImage)
      end;
    finally
      try
         imgCover.free
      finally
         imgCover := nil;
      end;
    end;
  end;
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top