Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1290
  • Last Modified:

Quality of picturebox is very bad when loaded from imagelist

Hi there,

can anyone help?

I am using Visual Studio 2003, and i have loaded a png file 32 x 32 into an imagelist and then in my code i do

uxCollapsePictureBox.Image = imageList2.Images[0];

It does work but the image is very bad, i have set the Depth to 32 bit.

If i just load the image directly into the picturebox through properties rather than using an imagelist it very nice...

Am i missing something?

Thanks in advance

Ian
0
ianinspain
Asked:
ianinspain
  • 4
  • 2
1 Solution
 
ianinspainAuthor Commented:
Actually the i have just checked again and the image is fine but it has a blue sort of border around it...

Its a round picture and all around the edge is blue

Thanks

Ian
0
 
topdog770Commented:
I'm guessing that you are using blue as the transparency color.

Unforunately, the transparencykey color is displayed when a client machine is set to display 32 bit colors.

To confirm that this is the problem, adjust your display settings to show 16 bit colors or less and the blue border should disappear.
0
 
ianinspainAuthor Commented:
Hi .. thanks for reply.. No i have tried to change the transparency color and also tried setting my display to 16 bit colors... but its still the same...

Ian
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
vo1dCommented:
use a resource file instead of an image list.
have you setuped your imagelist dimension to 32x32?
0
 
ianinspainAuthor Commented:
Yes i did....  but a resource file sounds a better idea ....
0
 
ianinspainAuthor Commented:
You don't have any code to read from a resource file do you?

I am using Visual studio 2003
0
 
topdog770Commented:
To use this code.. I added a bitmap to the project and set it to 'embedded resource'

                  Stream imgStream = null;
                  Assembly a = Assembly.GetExecutingAssembly();
                  // attach to stream to the resource in the manifest
                  imgStream = a.GetManifestResourceStream  --> full namespace needed ("MY.PROJECT.NAMESPACE.Entertainment.BasicSplash.bmp");

  // side bonus.. this code gets around the 32bit color transparency bug in .net
                  if( !(null==imgStream) )
                  {                    
                        // create a new bitmap from this stream and
                        // add it to the arraylist
                        bitmap = Bitmap.FromStream( imgStream ) as Bitmap;
                        bitmap.MakeTransparent(bitmap.GetPixel(0,0));
                        this.BackgroundImage = bitmap;
                        this.TransparencyKey = bitmap.GetPixel(0,0);
                        imgStream.Close();
                        imgStream = null;
                  }      
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now