Windows Forms Topics include: windows forms, controls, components and designers

Go Back  Xtreme .NET Talk > .NET > Windows Forms > [VB.NET] Image from ImageList to PictureBox


Reply
 
Thread Tools Display Modes
  #1  
Old 12-08-2006, 07:00 PM
Nazgulled Nazgulled is offline
Centurion
 
Join Date: Jun 2004
Posts: 119
Nazgulled is on a distinguished road
Default [VB.NET] Image from ImageList to PictureBox



I have an ImageList with some images, all of them are png with transparency and the transparency is working correctly. The images are somekind of square with a little outline in a transparent background. On the main form, I have a picturebox that will take one of the images in the listbox. The image it will take will be different acording to some arguments, but that doesn't really matter I think.

To apply the pictures I do something like this:

frmMain.pic1Enabled.Image = frmMain.imgLabels.Images.Item(0)

The problem is that the image does not have the correct colors I designed in the first place. The outline is somewhat blue where it should be gray. The rectangle background is also a little blueish...
Reply With Quote
  #2  
Old 12-08-2006, 07:25 PM
snarfblam's Avatar
snarfblam snarfblam is offline
Ultimate Contributor

Preferred language:
C#, VB
 
Join Date: Jun 2003
Location: USA
Posts: 2,097
snarfblam will become famous soon enough
Default

Try setting the ImageList's ColorDepth property. By default it is 8 bits per pixel, which is just, well, silly, because it makes gradients, detailed color, and alpha transparency look all kinds of bad. You may or may not have to remove the images from the ImageList and then reload them (after you change the ColorDepth) in order for them to appear correctly.
__________________
e
Reply With Quote
  #3  
Old 12-08-2006, 08:04 PM
Nazgulled Nazgulled is offline
Centurion
 
Join Date: Jun 2004
Posts: 119
Nazgulled is on a distinguished road
Default

That is not the problem, the first thing I did when creating the imagelist was setting it to "Depth32Bit" otherwise the PNG transparency wouldn't work...
Reply With Quote
  #4  
Old 12-09-2006, 01:14 PM
snarfblam's Avatar
snarfblam snarfblam is offline
Ultimate Contributor

Preferred language:
C#, VB
 
Join Date: Jun 2003
Location: USA
Posts: 2,097
snarfblam will become famous soon enough
Default

Then I can't think of a reason why this shouldn't work. Have you tried reloading the images into the ImageList? Is the ImageList populated at run-time or design-time? Maybe you ought to post the code that populates the ImageList and the code that takes the image from the ImageList and shows it in the PictureBox.
__________________
e
Reply With Quote
  #5  
Old 12-09-2006, 02:20 PM
Nazgulled Nazgulled is offline
Centurion
 
Join Date: Jun 2004
Posts: 119
Nazgulled is on a distinguished road
Default

The ImageList is populated at design-time and the code that takes the image from the ImageList and shows it in the PictureBox is already in the first post.

For the generated designer code, check this file:
http://stuff.nazgulled.net/code/vb.n...er.Designer.vb

The ImageList control is called imgLabels and the PictureBox controls that will take images from it are named pic1Enabled, pic2Enabled, pic1DHCP and pic2DHCP.
Reply With Quote
  #6  
Old 12-10-2006, 09:46 AM
Nazgulled Nazgulled is offline
Centurion
 
Join Date: Jun 2004
Posts: 119
Nazgulled is on a distinguished road
Default

Nevermind, I kinda fixed it. Instead of using an ImageList, I add all images to the resources file and used My.Resources. Now the colors work correctly.
Reply With Quote
  #7  
Old 09-01-2011, 12:40 PM
L3GACY818 L3GACY818 is offline
Newcomer
 
Join Date: Sep 2011
Posts: 1
L3GACY818 is on a distinguished road
Thumbs up Re: [VB.NET] Image from ImageList to PictureBox

Quote:
Originally Posted by snarfblam View Post
Try setting the ImageList's ColorDepth property. By default it is 8 bits per pixel, which is just, well, silly, because it makes gradients, detailed color, and alpha transparency look all kinds of bad. You may or may not have to remove the images from the ImageList and then reload them (after you change the ColorDepth) in order for them to appear correctly.

I was having the same problem and bumped into this forum. If the clarity of your picture is not working properly when retreiving the image from an imageList and transferring to a picturebox, it's most likely because you must change the ColorDepth property first. Then, you reload your images into the imageList collection, manually, like you did when you set up the collection.

Thanks snarfblam for providing the correct path to take when having the issue this forum was set up for.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Picturebox image value hog Windows Forms 2 07-26-2005 11:08 AM
Getiing Image name from PictureBox Erdenemandal Graphics and Multimedia 2 07-07-2005 02:34 AM
Copying a stretched image from a PictureBox to another picturebox qmp Graphics and Multimedia 1 07-05-2005 07:04 PM
Image equivalence to PictureBox adude Graphics and Multimedia 1 11-16-2004 07:14 PM
ImageList Image to Icon Nazgulled Windows Forms 4 10-13-2004 10:31 AM

Advertisement:







Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe