# Picture.Graphics is Nil?

**URL:** <https://forum.xojo.com/t/picture-graphics-is-nil/33491>\
**Category:** Getting Started\
**Created:** [September 19, 2016, 11:35am UTC](https://forum.xojo.com/t/picture-graphics-is-nil/33491 "2016-09-19T11:35:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mathias\_Maes](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/7c8e57/32.png) [@Mathias\_Maes](https://forum.xojo.com/u/Mathias_Maes)\
**Post date:** [September 19, 2016, 11:35am UTC](https://forum.xojo.com/t/picture-graphics-is-nil/33491/1 "2016-09-19T11:35:29Z")

</div>

Hello

I open a picture on my computer, and want to access the graphics. The picture is not nil, but the graphics are Nil. How is this possible?

[code] Dim picFile As FolderItem  
picFile = GetOpenFolderItem()

If picFile \<\> Nil Then  
Dim pic As Picture  
pic = Picture.Open(picFile)

```
pic = ModernizePicture(pic)

pic.Graphics.ForeColor = &cFFFFFF
pic.Graphics.TextUnit = FontUnits.Pixel
pic.Graphics.TextSize = 50[/code]
```

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [September 19, 2016, 11:38am UTC](https://forum.xojo.com/t/picture-graphics-is-nil/33491/2 "2016-09-19T11:38:43Z")

</div>

some pictures are read only and than graphics is nil.

---

<div class="post-metadata">

**Author:** ![Mathias\_Maes](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/7c8e57/32.png) [@Mathias\_Maes](https://forum.xojo.com/u/Mathias_Maes)\
**Post date:** [September 19, 2016, 11:52am UTC](https://forum.xojo.com/t/picture-graphics-is-nil/33491/4 "2016-09-19T11:52:31Z")

</div>

Just tested, picFile.IsWriteable returns true.

---

<div class="post-metadata">

**Author:** ![Sascha\_S](https://forum.xojo.com/user_avatar/forum.xojo.com/sascha_s/32/22328_2.png) [@Sascha\_S](https://forum.xojo.com/u/Sascha_S)\
**Post date:** [September 19, 2016, 11:53am UTC](https://forum.xojo.com/t/picture-graphics-is-nil/33491/5 "2016-09-19T11:53:59Z")

</div>

> [@287606:@Mathias Maes](#):
>
> ModernizePicture(pic)

What does “ModernizePicture” do? Can you post the Code please?

---

<div class="post-metadata">

**Author:** ![Mathias\_Maes](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/7c8e57/32.png) [@Mathias\_Maes](https://forum.xojo.com/u/Mathias_Maes)\
**Post date:** [September 19, 2016, 12:00pm UTC](https://forum.xojo.com/t/picture-graphics-is-nil/33491/6 "2016-09-19T12:00:03Z")

</div>

Hello

It was the ModernizePicture function from this page: [http://documentation.xojo.com/index.php/Picture](http://documentation.xojo.com/index.php/Picture)

But I found out what was wrong. It had something to do with HiDPI support.

ModernizePicture was:

[code] If input.hasAlphaChannel Then Return input

Dim result As New Picture( input.Width, input.Height )  
result.HorizontalResolution = input.HorizontalResolution  
result.VerticalResolution = input.VerticalResolution  
result.Graphics.DrawPicture( input, 0, 0 )  
Return result[/code]

I deleted the first line, now it ALWAYS makes a new copy of the image. Now it works. I totally don’t understand why an image would be immutable because of HiDPI, but apparently, it is.

Read here: [http://blog.xojo.com/2016/04/05/xojo-retinahidpi-the-journey-of-a-thousand-pixels/](http://blog.xojo.com/2016/04/05/xojo-retinahidpi-the-journey-of-a-thousand-pixels/)

Thanks for thinking with me!

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:28pm UTC](https://forum.xojo.com/t/picture-graphics-is-nil/33491/7 "2020-10-29T18:28:10Z")

</div>


