How do you add icons to a stack?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

noloop
Posts: 13
Joined: Thu Oct 07, 2010 2:26 am

How do you add icons to a stack?

Post by noloop » Sun Oct 10, 2010 5:01 am

I converted a Hypercard stack to a Revolution stack, and all the icons came along. Yay. I see them when I select an icon for a button, using the inspector. I can uset the "set icon of btn..." command to disaply them. The icons are not part of the image library, which is empty.

In trying to add icons to the rev stack, the only method I've found is to import a file into the image library. The image is then available as an icon.

The problem is that this automatically plops the image down onto the card, where I don't want it. I want it to be an icon stored in the stack, summoned by the "set icon..." command. I don't want it to be a graphic object independent of existence as an icon.

The really tedious way to do this would be to add the new icon I want to a Hypercard stack, and then convert the Hypercard stack. Surely there is a better way....

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Re: How do you add icons to a stack?

Post by Janschenkel » Sun Oct 10, 2010 9:10 am

The icons that came along from the HyperCard conversion, are actually stored as image controls in your stack, and simply hidden.
So when you import new icons, all you have to do is hide the images after import.

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

noloop
Posts: 13
Joined: Thu Oct 07, 2010 2:26 am

Re: How do you add icons to a stack?

Post by noloop » Sun Oct 10, 2010 4:40 pm

Hi. That can't be right, because the imported icons aren't listed in the image library. They are only presented when I select an icon for a button using the object inspector.

It seems cleaner to do it that way. I don't want random images that will never be displayed, except as button icons, scattered and hidden on random cards.

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Re: How do you add icons to a stack?

Post by Janschenkel » Sun Oct 10, 2010 7:07 pm

The image library is actually a completely separate stack. When you use the inspector to assign an icon to your button, you've probably switched to 'This stack' and seen the list of your old icons, converted from HyperCard. And yes, those are actually image controls in your stack, hidden from sight, but perfectly selectable as an icon.
The advantage of this LiveCode feature, is that you're not limited to a specific icon size or file type - just use any image. The image doesn't even have to be in the same stack file - as it can be stored in a substack; then all you need to remember is the ID of the image, and you can assign it directly in the inspector.

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

noloop
Posts: 13
Joined: Thu Oct 07, 2010 2:26 am

Re: How do you add icons to a stack?

Post by noloop » Mon Oct 11, 2010 5:06 am

I've gone ahead and started using icons this way. Now the problem is the Revolution doesn't seem to recognize transparent areas in a png image. I displays the areas between the actual image and the sides of the rect as white, no matter what I do. Does Revolution recognize transparency?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: How do you add icons to a stack?

Post by bn » Mon Oct 11, 2010 9:11 am

Hi noloop,
Rev honors the transparencies of a png. Once imported you can actully play with the transparency of an image object which is the alphadata. I don't quite get what you are seeing. Would it be possible to upload a small example? And a zipped version of a png you are using?

regards
Bernd

noloop
Posts: 13
Joined: Thu Oct 07, 2010 2:26 am

Re: How do you add icons to a stack?

Post by noloop » Tue Oct 12, 2010 5:31 am

Hello. This rev stack contains a .png image that has a trnasparent background (according to GraphicConverter). The transparent background is opaque white on the card.

I've noticed that if I go into "Blend" and choose transparent, that it works. But it's buggy in certain situations, such as unlock screen with visual "wipe right". Also, I don't think that can be the correct solution, because it seems to work (sort of) regardless of whether the background of the image is set to transparent or white.
Attachments
pngtest.rev.zip
(1.17 KiB) Downloaded 293 times

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: How do you add icons to a stack?

Post by WaltBrown » Tue Oct 12, 2010 6:32 am

FYI, when I opened the stack both images were transparent for me. I'm running Vista x64 on an NVIDIA 9200M.
Walt
Walt Brown
Omnis traductor traditor

noloop
Posts: 13
Joined: Thu Oct 07, 2010 2:26 am

Re: How do you add icons to a stack?

Post by noloop » Tue Oct 12, 2010 7:02 am

That's weird. I'm running Revolution 3.5 on Mac OS 10.5.8

Bantymom
Posts: 73
Joined: Fri Aug 27, 2010 4:32 am

Re: How do you add icons to a stack?

Post by Bantymom » Tue Oct 12, 2010 9:39 am

Just to add information:

RevMedia 4.0
Mac OS 10.6.4

I see black figures on white squares on a blue field.

I tried gifs that I had saved with as few colors as possible to get rid of the grayed pixels on the edges that looked like white specks around my images (though one refused to work that way and I had to go in and remove each of them one by one) Those did work, but I wasn't happy with where the name of the button kept ending up, so I used the images grouped with transparent buttons. I'm going to try again soon to use them as icons, though.

Cheers,
Bantymom
2nd-grade Teacher, Poultry Fancier, Scottish Country Dancer
and Perpetual Beginner

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: How do you add icons to a stack?

Post by bn » Tue Oct 12, 2010 12:03 pm

Hi noloop,

I don't know why transparency works for Walt but not for you, bantymon nor me. All three of us on a Mac. You can create PNGs with or without alphachannel = transparency. It would be interesting if Preview shows transparency or not. Maybe there is something wrong with your PNGs.

Anyhow, to show that PNGs work with rev I took your stack, copied the image, renamed it and did this:
choose any color of the bucket tool colors, choose the bucket tool, then right-click in a white portion of the image. This is an eraser function taking color information from the image and making it transparent.

In the attached stack I added a button to export this modified image to the desktop (look at it in Preview, it is called "emptyHandedII.png") and then reimport it with the button below the export button. -> with transparency.

regards
Bernd
Attachments
pngQuestion.rev.zip
(2.26 KiB) Downloaded 291 times

noloop
Posts: 13
Joined: Thu Oct 07, 2010 2:26 am

Re: How do you add icons to a stack?

Post by noloop » Tue Oct 12, 2010 10:27 pm

For me, that works for the image, but not when using the image as a button icon. It's still white where it should be transparent. Hm....

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: How do you add icons to a stack?

Post by bn » Tue Oct 12, 2010 11:22 pm

noloop,
if I set the button icon to the id of the reimported png it is transparent.
Please have a look at the stack I appended to above message.
Edit: I just did it on a image that was defined an icon to the button and took away the white part with the bucket tool right click. When I went back to browse mode it had not updated the icon on the button yet. Switching to edit mode and back to browse mode updated the icon in the button. Could you try that?
regards
Bernd

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: How do you add icons to a stack?

Post by WaltBrown » Wed Oct 13, 2010 7:19 am

Brrnd, on your stack, the two images on the right are transparent EXCEPT between the legs of the dancer. Here is a JPEG of part of my screen showing both stacks. In Bernd's, I have clicked Export then Re-Import once each.
Walt
Attachments
IconStacksImage.jpg
IconStacksImage.jpg (65.29 KiB) Viewed 9109 times
Walt Brown
Omnis traductor traditor

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: How do you add icons to a stack?

Post by WaltBrown » Wed Oct 13, 2010 7:28 am

And here is a JPEG of the original PNG copied and pasted into Gimp, which clearly shows the alpha.
Walt
Attachments
FirstIconStackImage.jpg
FirstIconStackImage.jpg (98.49 KiB) Viewed 9108 times
Walt Brown
Omnis traductor traditor

Post Reply