Draw picture in picture, PDF edition

In Draw picture in picture @JulianS found out why my code for drawing a small picture in a larger picture doesn’t work. I’m adding BS style icons to my app and need to draw now the small icon in a larger icon for PDFs.

If I draw the 2 icons directly then everything works fine:

dim p as new Picture(folder_outline.Width, folder_outline.Height)
p.Graphics.DrawPicture(folder_outline, 0, 0)
p.Graphics.DrawPicture(exclamation_outline, 0, 0)

But when I add the small icon in the code I had written then I only get the original icon:

dim p as new Picture(folder_outline.Width, folder_outline.Height)
p.Graphics.DrawPicture(folder_outline, 0, 0)
p = AddExclamation(p, true)
g.DrawPicture(p, 0, 0)

In the logic of the code I give the listbox the finished icon which is then responsible for drawing.

What am I doing wrong? The debugging isn’t helped by having the PDF show up as great white or black emptyness.

Example project is available at http://www.mothsoftware.com/downloads/exclamation.zip

Xojo 2020r2 on High Sierra.

Do you need ResultPicture.ApplyMask OriginalPicture.CopyMask ? You’re putting the mask of the image back to where it was before you made the change.

There is a problem with the masks of the PDFs. For inverting, for instance, I had to do some gyrations:

dim p as Picture = theRow.IconOutline.CopyMask.InvertMBS
p.ApplyMask(theRow.IconOutline.CopyMask)

@Jeremie_L : g is from the paint event.

I deleted my previous reply because I downloaded the project and noticed that g is from the paint event.

I was too fast :grinning:

Could you include the two missing images so we can test the project?

The pictures should be in the zip file: Screenshot 2021-04-17 at 15.14.08

In AddExclamationInner line 22, commenting this line:
'ResultPicture.ApplyMask OriginalPicture.CopyMask
will display the exclamation outline.

The problem here is that the mask of the folder is hiding the exclamation mark displayed in the center.

1 Like

If you remove the .CopyColorChannels from the DrawPicture does that preserve the mask ok when you need to run them through the invert? Can you then remove the ApplyMask ?

1 Like

@Jeremie_L + @JulianS : great, I needed to change both lines and now the icons displays fine.

1 Like