image button verus drawing button

modularbeing

Well-known member
Joined
Jan 8, 2004
Messages
63
I want to create some custom button controls with a skinnable look to them. I was thinking about taking an image and using it as a button but then I got to thinking that if I have 10 different buttons on the screen using 10 different images that it might consume a good chunk of memory. Does anyone know how badly doing this may affect memory versus just drawing some sort of button using system.drawing ??

thanks
 
Other than your file size, I dont think that image buttons take up any more RAM than code drawn buttons...as they are both displayed in the same manner on the same screen with the same pixel resolution etc. But all that said, I feel that it really depends on the complexity of the button graphic as to whether to code or draw.
 
I agree with you as well on the complexity of it but since I want to allow skinning I figured images would be the best way, it would be nice if I could load the image and draw it to the screen then dump it out of memory.
 
Oh one more thing I forgot to ask: I know that I can use a gif to have transparent areas on an image but the quality of the format can be lacking. I believe I saw something in the framework for setting a transparency color, would it be possible to load a jpeg and use this feature to make an area transparent?
 
Firstly, what image are you going to replace with a button image...its the same RAM, with the same pixel resolution...etc.

And, doing a search for Transparent in this forum returned a lot of very good examples of rendering "transparent" backgrounds for controls.
 
the transparency I was refering to making a color of an image transparent using gdi+ and drawing it to the screen. Ill search for something like that on the forum.

the button control I want to make will be an image drawn to the screen by overriding the paint event of the button control(i think this is how to do it I still need to do more reading into it). I just didnt know if there was a way to draw it to the screen and then dispose the image after its drawn so it does not consume memory consistantly. I am still learning about graphics with .net so im not sure if this would even be efficient.
 
I was once told, "Why re-invent the wheel?".

This holds true in this case.

If you ever have (or had) a chance to try out Macromedia Flash or Swish, you will see that a button is no more than 3 states and a Black and white Region that says if the button was clicked or not (by reading the color of a pixel in the region at the mouses location)

Because Bitmaps can be drawn to with the Graphics object, you can choose to load them with images OR draw your gradient fills, brushes, and what not. A buttons images need only be redrawn if the button changes size anyways, right?

1-MouseDown Bitmap
2-MouseOver Bitmap
3-MouseUp Bitmap

4-Hit Region - Black and White image to determine where button is clicked (by reading pixel color @ that location on the Region, not the actuall button)
 
Back
Top