Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • *Experts*
Posted
Other than your file size, I don't 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.

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Posted
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.
Posted
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?
  • *Experts*
Posted

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.

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Posted

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.

  • 4 weeks later...
Posted

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 mouse's 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 button's 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)

Me = 49% Linux, 49% Windows, 2% Hot gas.

 

...Bite me.

 

My Site: www.RedPierSystems.net

-.net, php, AutoCAD VBA, Graphics Design

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...