Page 1 of 2

DBRichViewEdit FieldFormat RTF and image size

Posted: Thu Jul 08, 2010 7:02 am
by alexd
Hi,

I'm testing with the trial version atm. We want to store a letter in our database using the DBRichViewEdit. As we're using report builder as our printing solution we added the ppDBRichView addon to report builder. After some testing I have a problem when the fieldformat of the DBRichViewEdit is set to RVF and I try to insert an image into the edit. When I switch to the report builder print preview the ppDBRichView field doesn't show the image. There is only some richview code visible. So I tried to change the fieldformat to RTF and the ppDBRichView shows all images. But when I insert an image to the DBRichViewEdit the image will be resized to about 10 pixel in height no matter how big the image is when I post the query. When I resize the image again after posting it keeps it original size. I use the richviewactions for inserting images. When the fieldformat is set to RVF this behavior is gone. I already tried to call the Format and the Reformat function before and after posting without any effect.

Is there a special way of inserting images when the fieldformat is set to rtf so the DBRichView doesn't resize the images all the time?

Posted: Thu Jul 08, 2010 8:12 am
by Sergey Tkachenko
Is this a gif picture?
In this case, to load this picture from RVF, register it:
RegisterClass(TGifImage);
Call it one time before the first RVF loading.

As for RTF, there is a bug in saving sizes of converted gif picture (gif is converted to a metafile, because RTF format does not support gifs).
It is fixed in the latest version available for registered users.

Posted: Thu Jul 08, 2010 9:04 am
by alexd
I've tried to insert jpegs und pngs all with the same effect. Another solution would be to keep the RVF as fieldformat and have the ppDBRichView show the images. Isn't that possible?

Posted: Thu Jul 08, 2010 10:14 am
by Sergey Tkachenko
The problem with Png is the same as with the Gifs.
In order to load RVF with these images, you need to register this class:
RegisterClass(TPngImage); // or TPngObject
But there is a difference: Png images can be stored in RTF without converting to another format. To activate this mode, call
RV_RegisterPngGraphic(TPngImage);
(one time, before the first loading-saving; defined in CRVData unit)

As for Jpegs, they must not have this problem. TRichView registers TJPEGImage itself, so it can be loaded from RVF without additional code.
Jpegs are saved to RTF without converting to another format (if rvrtfSaveJpegAsJpeg is included in RichViewEdit.RTFOptions; it is so by default).

So:
1) If you want to use RVF format, register TGifImage and TPngImage using RegisterClass.
2) If you have problem with Jpeg image saved in RTF, please send this RTF to me, I'll try to see what's wrong. The same for PNG, if the problem persists after calling RV_RegisterPngGraphic(TPngImage).

Posted: Thu Jul 08, 2010 10:45 am
by alexd
Ok, I'll try what you suggested and will come back with the result asap.

Posted: Fri Jul 09, 2010 6:17 am
by alexd
So now I've set the fieldformat back to rvf before inserting a jpeg image. Just one jpeg image nothing else and this is what it looks like in the ppDBRichView field:

Image

When I set the format back to RTF everything looks good.

Posted: Fri Jul 09, 2010 6:20 pm
by Sergey Tkachenko
If DBRichView fails to load RVF or RTF, it displays the field content as a plain text.
What field type do you use? May be it cannot store binary data? (for RTF, any memo field can be used, because this is a text format; but for RVF, a binary field type is required)

Posted: Sun Jul 11, 2010 3:53 am
by alexd
If changed the fieldtype of the db field from ftMemo to ftBlob without any result. Even if I want to insert an BMP image that I've made with Paint the ppDBRichView wont show it. I've tried to insert an image into a table cell and the ppDBRichView shows the table but not the image in the cell. Again no matter what kind of image I insert into the cell.

Posted: Sun Jul 11, 2010 8:31 am
by Sergey Tkachenko
How do you change a field type?

Posted: Sun Jul 11, 2010 9:41 am
by alexd
Sorry for beeing not as precise as I wanted. I changed the BlobType of the query field to ftBlob. The dbms is firebird and the blobfield is defined as
BODY_TEXT_L01 BLOB SUB_TYPE 1 SEGMENT SIZE 80.

Posted: Mon Jul 12, 2010 3:18 pm
by Sergey Tkachenko
I am not familiar with firebird, however, as I can see from docs, the appropriate sub_type for RVF is 0, not 1.

Posted: Tue Jul 13, 2010 8:50 am
by alexd
You're right that the subtype should be 0 für the blob field, but I've already changed the field to subtype 0 and the error is still there.

Posted: Tue Jul 13, 2010 12:46 pm
by Sergey Tkachenko
Can you save the content of the field to a file and send this file to me?

Posted: Tue Jul 13, 2010 2:06 pm
by alexd
I've sent the file to the email address that is mentioned on your site.

Posted: Tue Jul 13, 2010 2:43 pm
by Sergey Tkachenko
Received.
You use TJpegGraphic class instead of TJPEGImage. This is not a standard class, it must be registered with RegisterClass.

PS: as for RTF export. Only images from TJPEGImage are stored in RTF as Jpegs. TRichView just does not know that TJpegGraphic contains a jpeg image, so, when saving RTF, it will be converted to a metafile or bitmap.