Ever since DarkMode I’ve had the 2 functions below to make pictures darker or lighter. There is one (!) instance where the function makes a very strange NOE.
The debugger shows me that MakeDarkerInner gives a picture back. But when making a new picture out of pp I can see that both pictures in pp are nil.
Xojo 2020r2.1, tested on Mojave and BS. The same code works fine in 2019r3.
Does anyone have an idea what I’m doing wrong?
Protected Function MakeDarker(original as Picture, amount as double) as Picture
Dim n As Integer=original.ImageCount
If n=0 Then
Return MakeDarkerInner(original, amount)
Dim pp() As Picture
for i as integer=0 to n
pp.Add MakeDarkerInner(original.ImageAt(i), amount)
Return new Picture(original.Width, original.Height, pp)
End Function Private Function MakeDarkerInner(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 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) next next ResultPicture.ApplyMask OriginalPicture.CopyMask End Function