C# Form image "distortion"

This is a discussion on C# Form image "distortion" within the C# Programming forums, part of the General Programming Boards category; I have a C# form application with a picturebox that has a company logo. I have the program compiled and ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    37

    C# Form image "distortion"

    I have a C# form application with a picturebox that has a company logo. I have the program compiled and running on a WinXP machine and Win2k3 and the image in the picture box is crystal clear.

    I tried running the application on a Win7 system and the image in the picturebox is extremely pixelated. I tried changing the image type I used from a gif to a jpg and even a png. I tried resizing, and changing the dpi but it always comes out distorted on the Win7 machine. It looks fine on a Vista system as well so this has me stumped.

    Has anyone run into a similar problem like this? I'm at a loss as to what could be going on. (I'll try to post some screenshots when I get back from lunch if those would help)

  2. #2
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Is the image being resized as it's displayed, or is the display size exactly equal to the actual image dimensions? C# is often bad at resizing by default; luckily it's pretty simple to fix. If it's just a logo, you probably should just make sure its display size is equal to its actual dimensions.


    For others' reference, though, or yours if you can't control the source or displayed image size for whatever reason, here's code that resizes an image with much better quality. Here 'img' is your source image, 'resizedImg' is your resized image. Obviously you'd need to change 128,128 to your actual desired output size (the actual pixels of your display):

    Code:
                Bitmap resizedImg = new Bitmap(128, 128);
                using (Graphics g = Graphics.FromImage(resizedImg))
                {
                    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    g.DrawImage(img, 0, 0, 128, 128);
                }
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 05:17 AM
  2. Simple Image Processing
    By ejohns85 in forum C++ Programming
    Replies: 4
    Last Post: 03-19-2009, 01:10 PM
  3. Image flickering in form
    By c9dw2rm8 in forum C# Programming
    Replies: 4
    Last Post: 04-06-2008, 05:00 PM
  4. background image on form
    By luigi40 in forum C# Programming
    Replies: 0
    Last Post: 07-14-2005, 06:41 AM
  5. Replies: 4
    Last Post: 03-02-2003, 09:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21