ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder
ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 ImageEN cannot open FireDac image
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ali

Iran
39 Posts

Posted - Aug 01 2019 :  05:55:30  Show Profile  Reply
Dear Nigel

In the attachment you can find a image which cannot open with ImageEN components and Photoshop and ACDSee only can show it image. It image worked by ImageEN components.
I use Delphi Rio and FireDAC for connect to SQL server 2014 and in below code:
1. DM1.FDspGetCardPicture.SaveToFile('C:\DBPhotoTemp.jpg');
With code I can save image and it image cannot open with ImageEN components and Photoshop and ACDSee only can show it image.

2.MainForm.BMP_UV_GRAY_ImageEn11.IO.LoadFromStream(Strm);
cannot show (open) image but ImageENDBView which connect to store procedure FDspGetCardPicture can show image!

3.Can I change a image to simple bmp/jpg file?
//////////////////////////////////////////////////////////////////
var
Strm: TMemoryStream;
begin
Strm:= TMemoryStream.Create;
DM1.FDspGetCardPicture.Close;
DM1.FDspGetCardPicture.ParamByName('@siCard').Value := DM1.FDMain_Query.FieldByName('sicard').AsInteger;
DM1.FDspGetCardPicture.Open;
DM1.FDspGetCardPicture.SaveToFile('C:\DBPhotoTemp.jpg');
DM1.FDspGetCardPicture.SaveToStream(Strm);
Strm.Position:=0;
MainForm.BMP_UV_GRAY_ImageEn11.IO.LoadFromStream(Strm);
//DM1.FDspGetCardPicture.SaveToFile('C:\DBPhotoTemp.jpg');
//MainForm.BMP_UV_GRAY_ImageEn12.Proc.ConvertToGray;
MainForm.BMP_UV_GRAY_ImageEn12.IO.LoadFromFile('C:\DBPhotoTemp.jpg');
//////////////////////////////////////////////////////////////////


attach/ali/2019815553_DBPhotoTemp.zip
208.36 KB

Best Regards

Ali Abbasi

xequte

4648 Posts

Posted - Aug 01 2019 :  21:56:01  Show Profile  Reply
Hi Ali

If you open this image in Notepad, you will see that it contain an image within, but before and after the image content is database information. I'm not sure how it became like this, but you might be better to ask on a database/FireDac forum for suggestions.

If an ImageEnDBView can show the image, then after loading you can use
ImageEnDBView.IO.SaveToFile(...);

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

ali

Iran
39 Posts

Posted - Aug 02 2019 :  03:02:47  Show Profile  Reply
Hi Nigel

Before send this post,I working by imageendbview.io.saveto (...).
But I want to use copy with stream imageen for send to ImageEN component for working.
My old project working exactly above codes with ADO without any problem,So this problem depended to ImageEN and FireDAC.
ImageEN and ADO do not have any problem.
If you find some codes for correct it image then fix it.

Want I connect ImagENDBView to image then ImagENDBView can open it and I can copy to orher ImageEn component, but ImagENDBView cannot show when I copy from database by stream to ImagENDBView which not connect to database?
If only ImagENDBView connect to database then
ImagENDBView show image!
Also ACDSee software can open it image,so if you develop imageen component for open it image similar ACDSee then fix it problem.

You told me which that it contain an image within, but before and after the image content is database information.
So,you change image to simple image with remove it information. I want to only open image with imageen component.

Where is FireDAC and imageen forum?

Best Regards

Ali Abbasi
Go to Top of Page

xequte

4648 Posts

Posted - Aug 04 2019 :  19:09:59  Show Profile  Reply
Hi Ali

In your code above, is FDspGetCardPicture a TFDQuery?

If so, you look to be saving the entire database content:

DM1.FDspGetCardPicture.SaveToFile('C:\DBPhotoTemp.jpg');


Shouldn't you just save the field content? e.g.

MyImageBlobField := DM1.FDspGetCardPicture.FieldByName('ImageFieldName');
MyImageBlobField.SaveToFile('C:\DBPhotoTemp.jpg');


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

ali

Iran
39 Posts

Posted - Aug 06 2019 :  07:04:30  Show Profile  Reply
Hi Nigel

Thank you, I will test it and notify you.
In your code above, is FDspGetCardPicture a TFDQuery?
FDspGetCardPicture is a Store procudure for SQL SERVER 2014.



Best Regards

Ali Abbasi
Go to Top of Page

ali

Iran
39 Posts

Posted - Aug 06 2019 :  07:32:00  Show Profile  Reply
Hi Nigel

I tested below code and ImageEn (BMP_UV_GRAY_ImageEn11) component cannot show 'DBPhotoTemp.jpg'.

DM1.FDspGetCardPicture.SaveToFile('C:\DBPhotoTemp.jpg');
MainForm.BMP_UV_GRAY_ImageEn11.IO.LoadFromFile('C:\DBPhotoTemp.jpg');

Regards

Ali Abbasi


Best Regards

Ali Abbasi
Go to Top of Page

xequte

4648 Posts

Posted - Aug 07 2019 :  03:36:20  Show Profile  Reply
Hi Ali

You are still saving the database content. Please try:

MyImageBlobField := DM1.FDspGetCardPicture.FieldByName('ImageFieldName');
MyImageBlobField.SaveToFile('C:\DBPhotoTemp.jpg');


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

ali

Iran
39 Posts

Posted - Aug 07 2019 :  23:37:37  Show Profile  Reply
Hi Nigel

FDspGetCardPicture is store procedure and it not query,so it code do not working.
I wrote other code which I saved jpg picture to a path and imageen cannot open it( you can see in the below).
If you will add a code for imageen which it code remove information (database information) and make a simple image then you will fix it problem.
I open it image with ACDSee software and save again then image convert to simple image and imageen and other software can open it image.

Strm:= TMemoryStream.Create;
DM1.FDspGetCardPicture.Close;
DM1.FDspGetCardPicture.ParamByName('@siCard').Value := DM1.FDMain_Query.FieldByName('sicard').AsInteger;
DM1.FDspGetCardPicture.Open;
DM1.FDspGetCardPicture.SaveToFile('C:\DBPhotoTemp.jpg');
DM1.FDspGetCardPicture.SaveToStream(Strm);
Strm.Position:=0;
MainForm.BMP_UV_GRAY_ImageEn11.IO.LoadFromStream(Strm);

If you have other code similar you last reply then send me complete codes for me.

Best Regards

Ali Abbasi
Go to Top of Page

ali

Iran
39 Posts

Posted - Aug 10 2019 :  12:05:05  Show Profile  Reply
Hi

Fixed my problem with below code:
.....
DM1.FDspGetCardPicture.Open;
TBlobField(DM1.FDspGetCardPicture.FieldByName('MyPicField')).SaveToFile('C:\DBPhotoTemp.jpg');
...


Best Regards

Ali Abbasi
Go to Top of Page

ali

Iran
39 Posts

Posted - Aug 11 2019 :  11:17:20  Show Profile  Reply
Hi

I cannot fixed my problem with below code for assign form FDspGetCardPicture (store procedure) to ImageEN component with below code.
Because after assign image to ImageEN component then it image is unreadable for ImageEN.

...
TBlobField(DM1.FDspGetCardPicture.FieldByName('photo')).SaveToStream(Strm);
...
Best Regards

Ali Abbasi
Go to Top of Page

xequte

4648 Posts

Posted - Aug 13 2019 :  00:33:09  Show Profile  Reply
Hi

Can you email me the resulting file/stream created by:

TBlobField(DM1.FDspGetCardPicture.FieldByName('photo')).SaveToStream(Strm);


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

ali

Iran
39 Posts

Posted - Aug 13 2019 :  02:01:15  Show Profile  Reply
Dear Nigel


Fixed my problem with below code:

DM1.FDspGetCardPicture.Close;
DM1.FDspGetCardPicture.ParamByName('@siCard').Value := DM1.FDMain_Query.FieldByName('sicard').AsInteger;
DM1.FDspGetCardPicture.Open;

TBlobField( DM1.FDspGetCardPicture.FieldByName('photo') ).SaveToStream(Strm);
Strm.Position:=0;
MainForm.BMP_UV_GRAY_ImageEn11.IO.LoadFromStream(Strm);
MainForm.BMP_UV_GRAY_ImageEn11.Proc.ConvertToGray;
MainForm.BMP_UV_GRAY_ImageEn11.IO.SaveToFile(FPathName + 'uv_dbphoto_temp.jpg');

Best Regards

Ali Abbasi
Go to Top of Page

xequte

4648 Posts

Posted - Aug 13 2019 :  16:42:46  Show Profile  Reply
OK, good one.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: