Makes loaded image clickable

14 posts / 0 new
Last post
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
Makes loaded image clickable

Hello,

i would like to load some images and make them "clickable". I'm not talking about "Button", but loaded 32 bit images blitted onto a window.

In the SDK example there is an example that shows how to do this with GIF images.

Any other way to create a clickable (or other events like mouse over) image?

Thank you

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
The ImageButtons example is

The ImageButtons example is not limited to GIF. It loads any type of image for which a datatypes class exists.

The bitmap.image class is not limited to loading picture files, either. It takes several different types of input data.

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
Thank you, Thomas. P.S. I

Thank you, Thomas.

P.S.

I tested and used your Fade example, and it's very nice and quite fast.

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
I tried to use Png insted of

I tried to use Png insted of gif, but the transparent area is visible.
There's a way to hide the transparent area using Png in Image Button?

salass00
salass00's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 11:27
@AmigaBlitter You need to

@AmigaBlitter

You need to set BITMAP_Masking to TRUE when creating the bitmap.image to make it use the alpha channel.

If it's the button border that you want to make invisible you should also set BUTTON_BevelStyle to BVS_NONE and BUTTON_Transparent to TRUE on the button.gadget object.

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
@salass00 i already use

@salass00

i already use these settings in button and image setup:

  1. IIntuition->NewObject(NULL, "button.gadget",
  2. GA_ID, OBJ_IBUT_1,
  3. BUTTON_BevelStyle, BVS_NONE,
  4. BUTTON_Transparent, TRUE,
  5. BUTTON_RenderImage, gadgets[OBJ_SEL] = /*BitMapObject,*/
  6. IIntuition->NewObject(NULL, "bitmap.image",
  7. BITMAP_SourceFile, "images/Object.png",
  8. BITMAP_DisabledSourceFile, "images/Object.png",
  9. BITMAP_Screen, scr,
  10. BITMAP_Masking, TRUE,
  11. /*BitMapEnd,*/
salass00
salass00's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 11:27
@AmigaBlitter Are you sure

@AmigaBlitter

Are you sure that your PNG file has a valid alpha channel? If it's a CLUT image with colour 0 as transparent you will want to use BITMAP_Transparent tag instead of BITMAP_Masking.

Also maybe you should clarify what you mean by "hide the transparent area"? I assumed you meant that you wanted the standard window background to show through in these areas but maybe it's something else that you want to happen?

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
Also maybe you should clarify

[quote]Also maybe you should clarify what you mean by "hide the transparent area"?/quote]

For transparent area i mean what is commonly used for sprite. Someone refer to it as "alpha channel", someone else as "transparent blitting".

Btw, using BITMAP_Transparent, TRUE, doesn't works either

salass00
salass00's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 11:27
@AmigaBlitter The question I

@AmigaBlitter

The question I asked wasn't what a transparent area is. I am perfectly aware of what that is. What I asked was what exactly you mean when you say want to "hide" them.

Also since you don't seem to be sure what pixel format your PNG image is in maybe you could upload it somewhere so I could look at it, as well as a screenshot of what it looks like currently when used in your program?

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
Here's the link for the png

Here's the link for the png image. I used Photoshop to create it. Could you suggest a good software that create the images in the right format?

https://skydrive.live.com/redir?resid=62EE0EAB9E6886C5%21733

As you can see, the image i tried to load in the button is a circular object (a ball). But i get a white rectangular border around it.

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
I tried with different

I tried with different Software to generate the PNG, but the results are always the same. Using GIMP i get a black border around the ball.

salass00
salass00's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 11:27
@AmigaBlitter It's a 32-bit

@AmigaBlitter

It's a 32-bit PNG alright so it has an alpha channel but currently it's set to fully opaque so it doesn't do any good.

Someone who is more familiar with GIMP might be able to tell you how to use it to edit the alpha channel of your PNG file. Since the pixels that should be fully transparent seem to be all white you could probably use that to create a very rough first alpha channel. After that you probably want to set some of the edge pixels to be semi-transparent rather than fully opaque to get a kind of antialias effect on the edges.

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
Thank you salass00. However

Thank you salass00.

However this is rather strange. I always used this format in Windows and had no problem with every Adobe software. Dunno why i cannot set the alpha properly this time.

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
Fixed now. It works

Fixed now. It works properly.
Somehow i modified (without realizing it) the creation of a new image (Photoshop/Gimp) with background color, instead of transparent color as it should be.

Log in or register to post comments