Jump to content

ULIK

Members
  • Content Count

    39
  • Joined

  • Last visited

Community Reputation

1 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi, when I print an image using GDI+ DrawImage method on a high DPI system (192 DPI), the result differs from what printer is used. Next is my test code: procedure TForm1.Button1Click(Sender: TObject); var DC: HDC; gpGraphics: TGPGraphics; gpImage: TGPBitmap; gpPen: TGPPen; nLogPixUI: Integer; nLogPx: Integer; png: TpngImage; rDest: TGPRectF; rectImage: TRect; rectImage72: TRect; begin memo1.Clear; // Just to get some information on the image png := TPngImage.Create; try png.LoadFromFile('image.png'); memo1.Lines.Add(Format('PNG.Width: %d', [png.Width])); memo1.Lines.Add(Format('PNG.Height: %d', [png.Height])); memo1.Lines.Add(Format('PNG.Res: %d, %d', [png.PixelInformation.PPUnitX, png.PixelInformation.PPUnitY])); finally png.Free; end; if PrintDialog1.Execute(Handle) then begin Printer.BeginDoc; try gpGraphics := TGPGraphics.Create(Printer.Canvas.Handle); try // let's use pixel gpGraphics.SetPageUnit(UnitPixel); // get device DPI DC := gpGraphics.GetHDC; try nLogPx := GetDeviceCaps(DC, LOGPIXELSX); memo1.Lines.Add(Format('Log. Pixel Device: %d', [nLogPx])) finally gpGraphics.ReleaseHDC(DC); end; // and create an image rectangle based on some MS Ink coordinates nLogPixUI := Screen.MonitorFromWindow(Self.Handle).PixelsPerInch; memo1.Lines.Add(Format('Log. Pixel Screen: %d', [nLogPixUI])); // create the image rectangle, based on a 90x90 pixel rectangle (just for test) rectImage.Create( MulDiv(10, nLogPx, nLogPixUI), MulDiv(10, nLogPx, nLogPixUI), MulDiv(100, nLogPx, nLogPixUI), MulDiv(100, nLogPx, nLogPixUI) ); // center coordinates system on image midpoint gpGraphics.TranslateTransform(rectImage.CenterPoint.X, rectImage.CenterPoint.y); gpPen := TGPPen.Create(ColorRefToARGB(ColorToRGB(clRed)), 1); try // create a red rectangle around the image gpGraphics.DrawRectangle(gpPen, - rectIMage.Width/2, - rectImage.Height/2, rectImage.Width, rectImage.Height); // load the image gpImage := TGPBitmap.Create('image.png', False); try memo1.Lines.Add(Format('Img.Width: %d', [gpImage.GetWidth])); memo1.Lines.Add(Format('Img.Height: %d', [gpImage.GetHeight])); memo1.Lines.Add(Format('Img.Res: %f, %f', [gpImage.GetHorizontalResolution, gpImage.GetVerticalResolution])); // create the destination rectangle for printing based on rectImage rDest.X := -rectIMage.Width/2; rDest.Y := -rectIMage.Height/2; rDEst.Width := rectIMage.Width; rDest.Height := rectImage.Height; gpGraphics.SetInterpolationMode(InterpolationModeHighQualityBicubic); gpGraphics.SetSmoothingMode(SmoothingModeHighQuality); gpGraphics.DrawImage(gpImage, rDest, 0, 0, gpImage.GetWidth, gpImage.GetHeight, UnitPixel); finally gpImage.Free; end; finally gpPen.Free; end; finally gpGraphics.Free; end; finally Printer.EndDoc; end; end; end; When I run this code against the attached image (see below) on a 96 DPI desktop system, everything is fine when printing on Microsoft PrintToPDF as well as any other installed printer: Next I run the same code on a SurfacePro 7 with 192 DPI. Now the result differs from used printer: HP Universal PS as well as SnagIt produce the expected output: But Microsoft Print to PDF, OneNote for Windows 10 and a HP Laserjet 400 MFP M425dw (607BA1) printer creates a wrong output: rectangle size is fine but content not. So the question is: why produces the output on different printers different outputs? It looks like the wrong output includes some scaling between 96 and 192 DPI but DrawImage should be independent of it, when setting source, destination explicitly. Especially why this is printer dependent? Any ideas, what causes this problem? Thanks, Ulrich forgot to mention: Delphi XE 10.2 Tokyo used image for printing:
  2. Thank you! The workaround is working 🙂
  3. Hi! can anyone confirm this bug (?): Delphi 10.2.3, MMX 15.0.11 Build 2371 - create a new unit - type the following class declaration: TMyClass = class(TObject) private FTest: Integer; public property Test: integer read FTest write FTEst; end; - now select the property on MMX code explorer and hit Ctrl+E to edit it Here this results always in this message: kind regards, Ulrich
  4. ULIK

    MMX Code Explorer V15 released

    There is a very small glitch on 'Add Event' dialog: the header caption of first tab displays the caption of the dialog instead just 'Event' as the other Add ... dialogs would indicate. I can't remember if this is related to MMX 15 or has always been there.
  5. ULIK

    MMX for Delphi 10.3 Rio

    Just installed this latest version: now opening the new property dialog is fast: just a second instead of more then 10 seconds! Thank you very much for your fine work!
  6. ULIK

    MMX for Delphi 10.3 Rio

    Thanks for explaining!
  7. ULIK

    MMX for Delphi 10.3 Rio

    No sure that I understand you right: adding a new property to a class is not so much uncommon for me (and that's what I did: selecting the new TForm1 object and added a property. Or do you mean that there is MMX internal code doing some strange things?
  8. ULIK

    MMX for Delphi 10.3 Rio

    Yes, opening the dialog the very first time requires about 13-16 seconds, also without CodeSite logging enabled.
  9. ULIK

    MMX for Delphi 10.3 Rio

    Great, now I get the logs. I enabled 'Check Packages' on 'General' settings again and tested it again: - starting the IDE - creating a new VCL App - adding a new property Still that long delay on first loading. See attached log file. MMX_Commented.csl
  10. ULIK

    MMX for Delphi 10.3 Rio

    Uwe, having just installed this new beta, I failed to get CodeSite Logs running. I installed MMX as 'Just for me' and applied the registry change: I have set both loggers to '1' and started the IDE and tried to create such a log. But until now, nothing has been written to My CodeSite Files\Logs nor to my CodeSite Live Viewer. Is there a way to check if logging is active? At the moment my test steps were: creating a new VCL app, then added a new property by MMX Editor. Should this write some log entries? I also checked my CodeSite dispatcher log and can't see any entries.
  11. Thanks! So I will use SourceForge for issues regarding GExperts
  12. Hi Thomas, as I'm not sure if comments on SourceForge bugs getting you attention, so I post here too: I have added some comments on issue #79: https://sourceforge.net/p/gexperts/bugs/79/ It would be fine if you could check the proposed change (and most probably complete my missed parts) In short, the expanded template seems to be added fine but deletion of template code fails as it considers the position as character based while the expansion calculated it byte based. Thank you!
  13. ULIK

    MMX for Delphi 10.3 Rio

    Yes, Pre-parse editor files is activated: But I think I found the problem: as soon as 'Check Packages' is disabled, I can't reproduce it any more. I played with that four options: disable all 4 and everything is fast, then activate 'Check Packages' only, restart IDE and it slows down to 10 seconds. Could it be that this information is collected only once at first use in IDE but not persisted (at least I did not found any file related to it)
  14. ULIK

    MMX for Delphi 10.3 Rio

    Are you sure that this path is used? I deleted both MMX-History.xml as well as BDS19_known_modules.xml from that path (after closing the IDE) and restarting IDE, I can still reproduce this and the dropdown still shows that enormous data. I have installed MMX to be available only for me.
  15. ULIK

    MMX for Delphi 10.3 Rio

    Uwe, here are some steps with that I can reproduce this performance problem on XE 10.2.3 every time. close any project on IDE close IDE start IDE again create a new VCL app (you should now be on [unmodified] standard layout) open MMX Explorer (by menu) select TForm1 entry press Ctrl+P (add new property) Now I have to wait for about 10 seconds until the dialog opens. The key point is this: you have to restart the IDE. Then only the first time the dialog opens it will show that delay. Just a guess: the dropdown list of the types: mine here contains several thousand entries (having heavy use of DexExpress library). Maybe the loading of that dropdown list slows the first start of the dialog.
×