Paste text and picture from office word,pictures changed crude
Paste text and picture from office word,pictures changed crude
I select some text and pictures then ctrl+c ,when I pasted to the TRichViewEdit,some pictures changed crude.Sometimes the same action is right in TSRichViewEdit. Single picture,none text ,the result is right.
In TSRichViewEdit:
In TRichViewEdit:
In TSRichViewEdit:
In TRichViewEdit:
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Paste text and picture from office word,pictures changed crude
Please send me a document where I can reproduce this problem.
Re: Paste text and picture from office word,pictures changed crude
The test docx sent to richview@gmail.com.Thank u!
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Paste text and picture from office word,pictures changed crude
I confirm the problem in scaling some pictures that have alpha channel.
I am trying to understand why it happens.
I am trying to understand why it happens.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Paste text and picture from office word,pictures changed crude
Try the following fix.
Open RVThumbMaker.pas.
Find
Change to:
(do it for the both 2 occurrences of this line)
Open RVThumbMaker.pas.
Find
Code: Select all
rgba.a := rgba.a + SrcPixel^.rgbReserved * Weight;
Code: Select all
if Weight > 0 then
rgba.a := rgba.a + SrcPixel^.rgbReserved * Weight;
Re: Paste text and picture from office word,pictures changed crude
Only copy and paste both text and picture mixed ,the images will change crude, single picture copy and paste is right.
The fix does not work,if I did fix right.But I'm confused for the paste action in the compiled demo ActionTests both TSRichView and TRichViewEdit ,it looks right. But I opened the demo app in delphi and run it,the result is wrong! What did I missed?
The fix I did in RVThumbMaker.pas:
The fix does not work,if I did fix right.But I'm confused for the paste action in the compiled demo ActionTests both TSRichView and TRichViewEdit ,it looks right. But I opened the demo app in delphi and run it,the result is wrong! What did I missed?
The fix I did in RVThumbMaker.pas:
Code: Select all
procedure ApplyHorizontally32;
var......
begin
.............
if IgnoreAlpha or (TempPixel^.rgbReserved <> 0) then
begin
Weight := WPMatrix[x, i].Weight;
rgba.r := rgba.r + SrcPixel^.rgbRed * Weight;
rgba.g := rgba.g + SrcPixel^.rgbGreen * Weight;
rgba.b := rgba.b + SrcPixel^.rgbBlue * Weight;
// rgba.a := rgba.a + SrcPixel^.rgbReserved * Weight;
if Weight > 0 then
rgba.a := rgba.a + SrcPixel^.rgbReserved * Weight;
end;
.............
end;
Code: Select all
procedure ApplyVertically32;
var...........
begin
..................
if IgnoreAlpha or (TempPixel^.rgbReserved <> 0) then
begin
Weight := WPMatrix[y, i].Weight;
rgba.r := rgba.r + TempPixel^.rgbRed * Weight;
rgba.g := rgba.g + TempPixel^.rgbGreen * Weight;
rgba.b := rgba.b + TempPixel^.rgbBlue * Weight;
if Weight > 0 then
rgba.a := rgba.a + TempPixel^.rgbReserved * Weight;
// rgba.a := rgba.a + TempPixel^.rgbReserved * Weight;
end;
....................
end;
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Paste text and picture from office word,pictures changed crude
May be the unit was not recompiled?
Try running "Install TRichView In Delphi IDE" in Windows start menu to recompile packages.
Try running "Install TRichView In Delphi IDE" in Windows start menu to recompile packages.
Re: Paste text and picture from office word,pictures changed crude
I did "insall in delphi IDE", the fix did not work.
Image in office word:
Paste to RVEditDemo.exe
Image in office word:
Paste to RVEditDemo.exe
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Paste text and picture from office word,pictures changed crude
Please send me a document with these pictures. With this fix, I cannot reproduce the problem on your previous document with a chart picture.
It may be another problem.
It may be another problem.
Re: Paste text and picture from office word,pictures changed crude
I have sent a test docx file to richview@gmail.com
Re: Paste text and picture from office word,pictures changed crude
Now I am sure,this problem happens in new version.The old compiled application worked perfect,But I don't know the version.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Paste text and picture from office word,pictures changed crude
Ok, I realized, there are two different problems here.
The first problem (that was fixed by the above provided code change) produced minor artifacts when scaling pictures that have an alpha channel (semitransparency). You can see the difference in this document before and after the fix if you load this document using LoadDocX method. In this case, images are imported as PNG. The images are correct, artifacts were produced by the TRichView's image scaling procedure.
The second problem is different. It happens when you copy this document from MS Word. In this case, document is inserted as RTF, and images are metafiles.
In this case, TRichView checks if these metafiles contain only raster images, and if yes, inserts them as bitmaps, instead of metafiles.
Obviously, older version of TRichView were not able to extract bitmaps from metafiles in this document, so they imported them as metafiles.
The new version can extract bitmaps, but these bitmaps are damaged for some reasons.
I'll try to find what's wrong. For now, you can simply disable extraction of bitmaps from metafiles by assigning RichViewEdit1.RTFReadProperies.ExtractMetafileBitmaps = False.
The first problem (that was fixed by the above provided code change) produced minor artifacts when scaling pictures that have an alpha channel (semitransparency). You can see the difference in this document before and after the fix if you load this document using LoadDocX method. In this case, images are imported as PNG. The images are correct, artifacts were produced by the TRichView's image scaling procedure.
The second problem is different. It happens when you copy this document from MS Word. In this case, document is inserted as RTF, and images are metafiles.
In this case, TRichView checks if these metafiles contain only raster images, and if yes, inserts them as bitmaps, instead of metafiles.
Obviously, older version of TRichView were not able to extract bitmaps from metafiles in this document, so they imported them as metafiles.
The new version can extract bitmaps, but these bitmaps are damaged for some reasons.
I'll try to find what's wrong. For now, you can simply disable extraction of bitmaps from metafiles by assigning RichViewEdit1.RTFReadProperies.ExtractMetafileBitmaps = False.
Re: Paste text and picture from office word,pictures changed crude
Everything is ok,thanks u:)
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Paste text and picture from office word,pictures changed crude
Well, I found the problem that caused this regression.
I'll include a fix in the next update.
I'll include a fix in the next update.
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Paste text and picture from office word,pictures changed crude
The fixes are included in TRichView 20.1 (uploaded today)