2016R1 - picture.graphics returns nil

Hi,

a previously fine code is not working any more in 2016R1. The error is that when
I access the picture.graphics (of private member) it returns a nil object error, even though the picture
in not nil.

    if ButtonIcon <> nil then 
      ButtonIcon.graphics.forecolor = RGB(255,255,255)
      if IsEnabled = False then ButtonIcon.graphics.forecolor = RGB(150,150,150)
      ButtonIcon.graphics.fillrect(0,0,ButtonIcon.width, ButtonIcon.height)
      g.DrawPicture (ButtonIcon, X_icon,Y_icon,ButtonIcon.Width/2,ButtonIcon.Height/2,0,0,ButtonIcon.Width,ButtonIcon.Height)
    end if

I tried to avoid this issue using picture.transparent but it gives no result, that is, it does
not change the transparency of my picture.

What’s the problem?

I have tested my curent project with the new release and had no issues so far. I use picture and/or drawing operation a lot.
Are you sure not having set buttonIcon to nil somwhere or can you make sure It’s not out of scope ?
ButtonIcon is a property ?

Have you read the HiDPISupport.pdf in the documentations folder? There have been a lot of changes to the picture class to support HiDPI. Could it be you now have an immutable bitmap which has no graphics object?

Did you enable HiDPI support for your project?

yes I did.

yes, right.

I should probably take a look at it. I was hoping a smoother transition though…

[quote=257901:@Davide Pagano]@Ulrich Bogun Have you read the HiDPISupport.pdf in the documentations folder? There have been a lot of changes to the picture class to support HiDPI. Could it be you now have an immutable bitmap which has no graphics object?
I should probably take a look at it. I was hoping a smoother transition though…[/quote]

HiDPI made picture immutable for the simple reason that depending on the scale, different pictures can be fetched. Instead of trying to modify the picture directly, create a picture of the same size, then drawpicture the original, and do the manipulations in that new picture, before making it the icon.

This works, for instance :

dim p as new picture(BevelButton1.icon.Width, BevelButton1.icon.height, 32) p.graphics.DrawPicture(BevelButton1.icon, 0, 0) p.transparent = 1 self.Backdrop = p

BTW I noticed when the picture is bigger than the BevelButton it covers it.
<https://xojo.com/issue/43313>

I did a blog post about converting the IDE to Retina. You may also find that helpful.

http://blog.xojo.com/a-journey-of-a-thousand-pixels