CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2007
    Posts
    274

    [RESOLVED] Rotated image appears somewhat blurry.

    Is there anyway to get around this? Basically I am trying to rotate an arrow that I am using in place of the treeview's plus/minus expander. When I rotate it -45 degrees, the arrow loses its border, or appears blurry.

    Here is my code for rotating the image:

    Code:
            private Image RotateImage(Image myImage, int myAngle)
            {
                Bitmap b = new Bitmap(myImage.Width, myImage.Height);
    
                Graphics g = Graphics.FromImage(b);
    
                g.TranslateTransform((float)b.Width / 2, (float)b.Height / 2);
                g.RotateTransform(myAngle);
                g.TranslateTransform(-(float)b.Width / 2, -(float)b.Height / 2);
                g.DrawImage(myImage,new Point(0,0));
                g.Dispose();
    
                return myBitMap;
            }
    Last edited by Traps; January 24th, 2009 at 05:15 PM.

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Rotated image appears somewhat blurry.

    That is going to happen when you rotate an image like that. Think about it; that image has to be created programmatically. That data does not exist, so some algorithm is used to try and find the best interpretation. There is a lot of anti-aliasing going on which makes it appear blurry. If you rotate it 90 degrees I am sure it looks fine. Not much you can do about it. If you open that image in a professional image editor the same thing will happen. Just avoid rotating it.

  3. #3
    Join Date
    Mar 2007
    Posts
    274

    Re: Rotated image appears somewhat blurry.

    Thats what I figured. I wanted to avoid drawing my own images. I'm horrible at that.

  4. #4
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Rotated image appears somewhat blurry.

    You could try using an editor like photoshop, GIMP, or Paint.net to do the rotation first. Maybe you'll get a better result. You would have to use two images instead of one.

  5. #5
    Join Date
    Mar 2007
    Posts
    274

    Re: Rotated image appears somewhat blurry.

    Quote Originally Posted by BigEd781 View Post
    You could try using an editor like photoshop, GIMP, or Paint.net to do the rotation first. Maybe you'll get a better result. You would have to use two images instead of one.
    Yeah, I dont have photoshop, never heard of GIMP or Paint.net. I'm playing around with IcoFX right now, seems pretty decent for a free editor, except it only saves as .ico files. I wanna make .png's

    I'm a complete noob when it comes to drawing/painting/graphics, so i'm just kinda stumbling along.

  6. #6
    Join Date
    Jun 2008
    Posts
    37

    Re: Rotated image appears somewhat blurry.


  7. #7
    Join Date
    Mar 2007
    Posts
    274

    Re: Rotated image appears somewhat blurry.

    Quote Originally Posted by Belzeski View Post
    Thanks, I am installing paint.net as I read your post.

    Wow, paint.net looks a lot like photoshop.
    Last edited by Traps; January 24th, 2009 at 08:54 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured