Hi,
In the last version a serious problem occurs for me.
When trying to load a picture in a TImage an error occurs and image is not displayed at all. Access violation in ntdll.dll
Actually even in the preview window the image is not displayed correctly is displayed cropped.
When using a TcxImage the image is displayed cropped and fitmode options (Strech, Proportional Strech) on't work.
Please this is urgent,
Best Reagrds,
Manolis Perrakis
Manolis,
It seems that you are right, there is an error in our new code related to metafiles. I have forwarded this ticket to our developers for research. Meanwhile I suggest that you try the following patch for the dxGDIPlusClasses.pas unit:
function TdxGPImage.GetAsBitmap: TBitmap; var ABitmapHandle: HBITMAP; begin Result := TBitmap.Create; Result.PixelFormat := pf32Bit; if (ImageDataFormat = dxImageWmf) or (ImageDataFormat = dxImageEmf) then begin Result.Width := Width; Result.Height := Height; Draw(Result.Canvas, cxRect(0, 0, Width, Height)); end else begin GdipCheck(GdipCreateHBITMAPFromBitmap(Handle, ABitmapHandle, 0)); Result.Handle := ABitmapHandle; end; end;
Applying this patch as a hot fix to our sources should solve the problem. I am looking forward to your feedback.
Posted by Manolis Perrakis:
Hi Paulo,
Thanks for the quick reply and for your effort to help me.
I applied the fix, the error doesn't occcur, however the wmf files
are displayed on the top left quarter of the preview and are cropped from the left.
This also occurs in the Image component (TImage and TcxImage)
they are placed on the top left quarter of the picture and are cropped from the left
when proportional strech is selected.
Thanks,
Manolis
Manolis,
I am afraid that I cannot reproduce the image cropping on my side. Would you please provide me with a small sample project (including the problematic wmf file)?
Thank you for your demo. I have forwarded it to our developers. Since fixing this issue may require time, I suggest that you temporary roll back to VCL 14.1.3.
P.S.: I kindly ask that you do not post your comments and additional info as solutions. This breaks the discussion logic. Thanks in advance.
Posted by Manolis Perrakis:
Hi Paulo,
Check attachment.
The rar contains a sample project and a sample wmf file.
Thanks,
Manolis
We have fixed the issue. However, since we do not have much wmf files on our side, I kindly ask that you test our fix with your real project. Please apply the following patch code to the dxGDIPlusClasses.pas file as a regular fix and let me know the result. I am looking forward to your feedback.
function TdxGPImage.GetAsBitmap: TBitmap; var ABitmapHandle: HBITMAP; AMetafile: TMetafile; begin Result := TBitmap.Create; Result.PixelFormat := pf32Bit; if ImageDataFormat in [dxImageWmf, dxImageEmf] then begin AMetafile := TMetafile.Create; try AMetafile.Enhanced := ImageDataFormat = dxImageEmf; AMetafile.Assign(Self); Result.Width := AMetafile.Width; Result.Height := AMetafile.Height; Result.Canvas.Draw(0, 0, AMetafile); finally AMetafile.Free; end; end else begin GdipCheck(GdipCreateHBITMAPFromBitmap(Handle, ABitmapHandle, 0)); Result.Handle := ABitmapHandle; end; end; //............... procedure TdxGPImage.SaveToMetafileStream(AStream: TStream; AEnhanced: Boolean); var AMetafile: TMetafile; ACanvas: TMetafileCanvas; begin AMetafile := TMetafile.Create; try if ImageDataFormat in [dxImageEmf, dxImageWmf] then begin ImageData.FData.Position := 0; AMetafile.LoadFromStream(ImageData.FData); AMetafile.Enhanced := AEnhanced; AMetafile.SaveToStream(AStream); end else begin {$IFDEF DELPHI10} AMetafile.SetSize(Width, Height); {$ELSE} AMetafile.Width := Width; AMetafile.Height := Height; {$ENDIF} ACanvas := TMetafileCanvas.Create(AMetafile, 0); try Draw(ACanvas, ClientRect); AMetafile.Enhanced := AEnhanced; finally ACanvas.Free; end; end; AMetafile.SaveToStream(AStream); finally AMetafile.Free; end; end;
Hi Paulo,
I've tried the fix it with dozen of files and it seems that everything is ok now.
Thanks,
Manolis
Thank you for your tests.
Hi Paulo,
I think there is still a problem regarding this issue.
I've tested the fix in my application in runtime.
However in design mode when you want to select a wmf file using the image picker the image is displayed cropped
And when you enter it in the image control again is displayed cropped.
This is not a serious problem for me but this also affects the report builder which I use as report in my application.
When I try to display in a image control these wmf files these also appear cropped both in design mode of the report
and also in the runtime mode.
Thanks,
Manolis
Hello Manolis,
That was not full hot fix code, but just a "quick solution" to fix the issue visual consequence. Now I have published the official hot fix here. So, please apply it as a regular fix, and reload all your images at design time to fix the dfm images data. I am looking forward to your feedback on this solution.
Hi Paulo,
You were right, after applying the fix everything is normal again.
Thanks,
Manolis
Great news! Thanks.