Image resizing quality vs basic photoshop resize

  1. ‹ Older
  2. 2 weeks ago

    Julian S

    Feb 14 Pre-Release Testers, Xojo Pro UK

    Break after ppx.Graphics.DrawPicture(p,0,0,newW,newH,0,0,p.Width,p.Height) and check that ppx.Graphics.AntiAliasMode was set to HighQuality

    Try the following, replace pic with your image, it works fine here on 2019r3.1 on W10 and Mojave, no jaggies

    https://www.dropbox.com/s/px2le8bw0203t79/TestImageResizeJagged.xojo_binary_project?dl=0

  3. Markus R

    Feb 14 Pre-Release Testers, Xojo Pro Europe / Germany / Lower Saxon...
    Edited 2 weeks ago

    no problem at xojo2019r31, there are no ugly hard edges.
    did you overwrite AntiAlias in graphics card driver?
    as i understood there is direct draw between at windows.

    i dropped your example picture into a project and then use a canvas to paint, direct and indirect
    in canvas i set all 4 anchor for testing it with window resize.

    Sub Paint(g As Graphics, areas() As REALbasic.Rect) Handles Paint
      Var pic As New Picture(256,512) 'just for test should have minimum the size of canvas or it get blurry
      pic.Graphics.AntiAliasMode = Global.Graphics.AntiAliasModes.HighQuality
      pic.Graphics.DrawPicture(TestAntiAliasMode,0,0,pic.Graphics.Width,pic.Graphics.Height,0,0,TestAntiAliasMode.Width,TestAntiAliasMode.Height)
      
      g.AntiAliasMode = Global.Graphics.AntiAliasModes.HighQuality
    'direct
      'g.DrawPicture(TestAntiAliasMode,0,0,g.Width,g.Height,0,0,TestAntiAliasMode.Width,TestAntiAliasMode.Height)
      
      g.DrawPicture(pic,0,0,g.Width,g.Height,0,0,pic.Width,pic.Height)
      
    End Sub
  4. Hello,
    in canvas, pictures can be drawn well if they were previously
    converted into a pixmap shape

    Var px As pixmapshape
    px = New pixmapshape(pix2)
    rem Draw smaller or larger in canvas with a mousewheel
    big As Double
    big= px.scale + deltay/30
    px.scale = big
    // mousedown:
    Picture.Graphics.DrawObject px,x,y
    //Paint:
    g.drawobject px,posx,posy

    rem or rotate
    rem With a timer you can also let the Pic2 turn automatically

    Var rotatingwheel As Double
    rotatingwheel = CDbl(angulardegrees.Text)+deltay
    If Abs(rotatingwheel) > 360 Then rotatingwheel=0
    angulardegrees.value = rotatingwheel.ToString
    If px <> Nil Then
    px.rotation=rotatingwheel / 57.29577951311
    Canvas1.Invalidate(False)// Paint:
    End If

  5. https://www.dropbox.com/s/0bzv7iz5xrjab74/test-angleandsize.xojo_binary_project?dl=1

  6. Michel B

    Feb 15 Pre-Release Testers, Xojo Pro

    @Tom I https://forum.xojo.com/9403-scale-quality-of-canvas-control

    Couldn't find an actual usable answer from there though.

    I am surprised. There were quite a bit of examples that produced good quality scaled down images. Have you tried any of the posted code ?

  7. Emile S

    Feb 15 Europe (France, Strasbourg)
    Edited 2 weeks ago

    Rudolf: pic2 is missing. I will use here a different one…

    Nice !

  8. last week

    Tom I

    Feb 17 Pre-Release Testers, Xojo Pro Chicago, IL

    @Rudolf J Hello,
    in canvas, pictures can be drawn well if they were previously
    converted into a pixmap shape

    This looks good on the canvas itself but does not have any improvement in image quality when using pixmapshape to draw into a new picture's graphics.

  9. Tom I

    Feb 17 Pre-Release Testers, Xojo Pro Chicago, IL

    @Markus R no problem at xojo2019r31, there are no ugly hard edges.
    did you overwrite AntiAlias in graphics card driver?
    as i understood there is direct draw between at windows.
    [/code]

    I'm trying to get a new picture object that can be saved to disk. It looks fine when drawing onto a canvas (especially if retina is enabled) but anything drawing to an actual picture object has the jagged edges.

  10. Tom I

    Feb 17 Pre-Release Testers, Xojo Pro Chicago, IL

    @Julian S Break after ppx.Graphics.DrawPicture(p,0,0,newW,newH,0,0,p.Width,p.Height) and check that ppx.Graphics.AntiAliasMode was set to HighQuality

    Try the following, replace pic with your image, it works fine here on 2019r3.1 on W10 and Mojave, no jaggies

    https://www.dropbox.com/s/px2le8bw0203t79/TestImageResizeJagged.xojo_binary_project?dl=0

    This looks fine on the canvas itself. But if you're drawing to a picture object (to save to disk) it has the jagged edges.

  11. Tom I

    Feb 17 Pre-Release Testers, Xojo Pro Chicago, IL

    @ChristianSchmitz You could use GMImageMBS class which has many more modes.

    Thanks Christian. These make a noticeable difference. Using these along with Emile Schwarz's idea for a two-step resize seems to get 90% of the quality of the photoshop resize.

  12. Markus R

    Feb 17 Pre-Release Testers, Xojo Pro Europe / Germany / Lower Saxon...
    Edited last week

    @Tom I I'm trying to get a new picture object that can be saved to disk. It looks fine when drawing onto a canvas (especially if retina is enabled) but anything drawing to an actual picture object has the jagged edges.

    ahh, ok, i not test the file output and at apple device.
    did you test DrawInto and then save the picture - if it looks better?

    Var p As New Picture(Me.Width, Me.Height)
    Me.DrawInto(p.Graphics, 0, 0)
  13. Emile S

    Feb 17 Europe (France, Strasbourg)

    @Tom I Emile Schwarz's idea for a two-step resize seems

    I’ve made an error the day I discovers that (I took an aready resized file instead of the full size one).

  14. Julian S

    Feb 17 Pre-Release Testers, Xojo Pro UK

    @Tom I This looks fine on the canvas itself. But if you're drawing to a picture object (to save to disk) it has the jagged edges.

    I'm not sure what you're doing differently, but it looks fine to me on win and mac, here's the converted image saved at 95% quality.

    -image-

    I've updated the code I posted to dropbox above to include the save shown here. This is processing the image you linked earlier.

  15. Julian S

    Feb 17 Pre-Release Testers, Xojo Pro UK

    @Julian S what version of macos and xojo are you using?

  16. hello Tom,
    new examble - save and load and Window2

    https://www.dropbox.com/s/4kt9zfamheh30i8/Testshapes-2.xojo_binary_project?dl=1

  17. Tom I

    Feb 17 Pre-Release Testers, Xojo Pro Chicago, IL

    @Julian S

    2019r3.1, and newest Catalina and Mojave (on two machines), and this is for a web app deployed to Xojo Cloud as well.

    The update to your project works here now for the edges though it definitely wasn't with the screenshot I posted above.

    Either way I went with the PictureMagick + multi step resampling because it still looks noticeably better than the simple anti-aliased update.

    Thank you for you help

  18. Hello Tom
    I have no spikes on the edges of my IMac 27 inch
    the pixmap shapes are vector graphics
    the quality is retained when saving
    call up the saved image and check
    see example

  19. sorry - correct link

    https://www.dropbox.com/s/uaqop1c6zcdls2w/test-angleandsize4.xojo_binary_project?dl=1

  20. Michael D

    Feb 17 Pre-Release Testers, Xojo Pro

    Tom, in this post https://forum.xojo.com/conversation/post/475513 you are looking at the picture in the Debugger - what's to say the debugger isn't mangling the picture when displaying it?

  21. Scott C

    Feb 17 Pre-Release Testers, Xojo Pro twitter.com/ScottCadillac

    @Michael D Tom, in this post https://forum.xojo.com/conversation/post/475513 you are looking at the picture in the Debugger - what's to say the debugger isn't mangling the picture when displaying it?

    The only time I find the debugger doesn't show me a correct representation of a picture, is when the Picture is part of an Image Set or an Array of bitmaps.

    To identify when this happens, look for the ImageCount value. If the ImageCount is greater than 0, then when you click on "Contents", I think the debugger only shows you the first image in the set (which is not necessarily the one you see in your app or output).

    -image-

    And as noted in ImageAt "...The individual pictures aren't necessarily stored/returned in ascending scalefactor order. Do not rely on a particular order for the pictures..."

    I only mention this because I came across a similar problem recently, when trying to debug why the correct scale sized picture wasn't showing when I expected it to. In my case, Picture.BestRepresentation fixed my issue.

or Sign Up to reply!