|
-
Jul 13th, 2007, 06:36 PM
#1
Thread Starter
Fanatic Member
[02/03] Loading an image at runtime to a control e.g. button
I want to load an image (.png) onto a button at runtime without using an imagelist.
The reason I do not want to use an imagelist is because the image quality deteriorates (goes all pixely) when an imagelist is used.
If I assign an image to a picturebox image property the image looks fine.
-
Jul 13th, 2007, 09:59 PM
#2
Re: [02/03] Loading an image at runtime to a control e.g. button
You have two good options:
1. Set the imagelist to the correct settings. By default, it resizes everything to 16x16.
2. Use a resource file instead of an image list.(recommended because images can all be different sizes)
You can assign them at run time from a file, but i don't recommend it.
-
Jul 14th, 2007, 01:06 PM
#3
Thread Starter
Fanatic Member
Re: [02/03] Loading an image at runtime to a control e.g. button
Regarding point 1)
The images are actually 16x16.
If you set the transparent colour of the imagelist to white
and set the image depth as 32bit the image then displays correctly when loaded into something with a white background, for example a listview item or picturebox.
The image does not display properly on a button because the background of the button is not plain white.
Hence the reason to load at runtime
Regarding point 2)
I have not tried that. I will have a hundred or so png files (16x16 images).
I don't want to have large resource files.
Maybe I'll have to try this to find out.
-
Jul 14th, 2007, 06:01 PM
#4
Re: [02/03] Loading an image at runtime to a control e.g. button
evidently what you think is white isn't exactly white on your images. It should not render the color if it is set to transparent. Open the image in a program that you can view the color value of a pixel (such as photoshop) and verify that red,green, and blue values are all 255 (&Hff). If they aren't(and i am POSITIVE this is the issue) then you have two choices: use a floodfill in a graphics program to replace the off-white with white in every single image,
or two: compute the correct value based on those three values (using the rgb function) and enter it as the transparency color in the listview. This is obviously much easier than the other method.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|