ImagePanel with autofit and zoom

Hi, Jim

Last month I posted a short example for using wx.DC. Please check the attached file if you like.
https://discuss.wxpython.org/t/comparison-of-rendering-speeds-of-several-toolkits-and-wx/35467/4

I have no idea the cause of the quality deterioration that da-dada pointed out. One possibility is the general problem when we resized down the picture: Aliasing or Moire.

For example, try this image.

Without any interpolation (normally ‘nearest’) you will see a pattern similar to the following:
sample_resized

This pattern can be produced like this. It is not as simple as 1+1=2… :wink:

import numpy as np

def ctf():
    N = 1024
    r = 20 * np.arange(-N/2, N/2) / N
    X, Y = np.meshgrid(r, r)
    f = np.sin(X**2 + Y**2)
    src = (255 * f ** 2).astype(np.uint8)
    buf = src.repeat(3,1).tobytes()
    return wx.Image(N, N, buf)

EDIT: Thank you this pointed out :arrow_up: Fixed.