I’m trying to update my homegrown HiDPI code with Xojo’s HiDPI stuff. But I’m getting totally confused. I’ve read the HiDPI guide but this is not much code. The docs also are pretty sparse. Additionally, I think having the same class “picture” contain different things (mutable or not) and that react different on different states is a really bad idea.
I’m trying to paint an icon in an “over” state deferred from the paint event:
Protected Sub drawOverState(g as graphics)
dim OverPicture as Picture = MakeDarker(ButtonPicture, 0.8)
g.DrawPicture(OverPicture, 0, 0)
The problem is the MakeDarker function:
[code]Private Function MakeDarker(OriginalPicture as Picture, theAmount as Double) as Picture
'change the value (lighter or darker) for the Original Picture
dim OriginalHeight as integer = OriginalPicture.height
dim OriginalWidth as integer = OriginalPicture.width
'dim mutablePicture as new Picture(OriginalPicture.Width, OriginalPicture.Height, 32)
'mutablePicture = OriginalPicture.CopyColorChannels
'dim OriginalRGBS as RGBSurface = mutablePicture.RGBSurface
dim OriginalRGBS as RGBSurface = OriginalPicture.RGBSurface
dim ResultPicture as new Picture(OriginalPicture.Width, OriginalPicture.Height, 32)
dim ResultRGBS as RGBSurface = ResultPicture.RGBSurface
for currentX as Integer = 0 to OriginalWidth
for currentY as Integer = 0 to OriginalHeight
dim theColor as Color = OriginalRGBS.Pixel(currentX, currentY)
ResultRGBS.Pixel(currentX, CurrentY) = HSV(theColor.Hue, theColor.Saturation, theColor.Value * theAmount)
ResultPicture.Mask = OriginalPicture.mask
The docs tell me that I need to use CopyColorChannels for HiDPI. If I try to use this I get an UnsupporteFormatException “CopyColorChannels is not supported for multi-representation images”. So I take the code out and then I get a NOE for the OriginalRGBS because the docs tell me that an unmutable picture doesn’t have an RGBSurface. What am I doing wrong here?
Are there any better examples?
Xojo 2017r3, macOS 10.11 and .13