lxn / walk

A Windows GUI toolkit for the Go Programming Language
Other
6.88k stars 887 forks source link

Set ImageView resize method (feature request) #568

Open StephanVerbeeck opened 5 years ago

StephanVerbeeck commented 5 years ago

ImageView always uses "Nearest Neighbor" method to resize the input bitmap to a smaller output display size (http://tech-algorithm.com/articles/nearest-neighbor-image-scaling/).

However this gives very poor results when it is applied to black and white scanned text document rendering them almost unreadable.

What would be needed to set the resize method or use one of the less primitive methods by default?

lxn commented 5 years ago

Canvas uses HALFTONE, but it seems AlphaBlend doesn't like it much.

Maybe we could StretchBlt to the desired size and then AlphaBlend that.

StephanVerbeeck commented 5 years ago

That was as far as I could follow it in source code. If there was a way to tell AlphaBlend what method to use (that would be great). But probably (like you mention) the simplest solution would be to have a temporary bitmap of the right size and use some other function to resize the bitmap before the alphablend (or use an alternative to alphablend).

lxn commented 4 years ago

This should work better now with https://github.com/lxn/walk/commit/df2b776509b17d535e2360371c5e314c00f13c8c.

StretchBlt followed by AlphaBlend sadly didn't work, as StretchBlt turns every transparent pixel into black.