Image resizing quality vs basic photoshop resize

I’m attempting to scale down photos to smaller previews, and pretty much every technique I’ve used results in jagged edges that look horrible. I’ve tried:

  • Simply drawing the new picture using the ppx.Graphics.DrawPicture(p,0,0,newW,newH,0,0,p.Width,p.Height) method
  • MBS plugin ScalingMBS (using all of the different options)

Photoshop uses bicubic resampling apparently and this must make a huge difference. Notice the difference between the two images below:


Any way to get a better image when reducing size?

There was a long thread about precisely that a while ago. Unfortunately, I was not able to locate it back.

I remember Ulrich Bogun shared his insight in there.

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

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

does this something different?

 ppx.Graphics.AntiAliasMode = Global.Graphics.AntiAliasModes.HighQuality

u can set this also in the paint event g.AntiAliasMode =

Can you link the original image so we can have a play?

Honestly struggling to tell which one you think is better and which was produced by each of the two methods.
maybe its the size, maybe its my eyes…
Does anyone expect a preview to be photo-glorious?

You could use GMImageMBS class which has many more modes.

Not the same but close enough:

Try this before your g.DrawPicture

g.AntiAliasMode = Graphics.AntiAliasModes.HighQuality

Edit: Oh Markus already mentioned this #include “glasses.h”

A two steps resize leads to a better result, but will it meets your needs ?

Resize a larger image once to an intermediate size, then resize that into the real target (needed) size. (simple DrawPictures)

Sorry for the delay, here’s the original:

[quote=475481:@Jeff Tullin]Honestly struggling to tell which one you think is better and which was produced by each of the two methods.
maybe its the size, maybe its my eyes…
Does anyone expect a preview to be photo-glorious?[/quote]
Look at the hair, as well as the outline of the blue hoodie, it’s much more pixellated and jagged in the top image (created using the app) vs the bottom image (created using Photoshop).

I use the ImagePlay Effects Library quite a bit. It’s got some nice functionality.

[quote=475479:@Markus Rauch]does this something different?

 ppx.Graphics.AntiAliasMode = Global.Graphics.AntiAliasModes.HighQuality

u can set this also in the paint event g.AntiAliasMode =[/quote]

This is about the same, it’s the bottom right in the screenshot below, top right is app without anti-alias setting, bottom left is photoshop.

Are you resizing it into a picture then resizing the picture again because it looks fine here on windows. It might be a mac thing, what version of macos and xojo are you using?

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

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.

[code]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
[/code]

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

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

[quote=475473:@Tom Iwaniec]https://forum.xojo.com/9403-scale-quality-of-canvas-control

Couldn’t find an actual usable answer from there though.[/quote]

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 ?