Rotating the picturebox image.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Rotating the picturebox image.

  1. #1
    Join Date
    Jun 2012
    Posts
    15

    Rotating the picturebox image.

    I've tried tons of materials in the web, but haven't quite been able to rotate the image. Could anyone post me how to do it? And yeah, I've been through the msdn site, but in vain.

    Thanks

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,583

    Re: Rotating the picturebox image.

    The only rotation supported by the Bitmap class itself is in 90-degrees increments, but I guess you have already seen that and it's not enough for your needs.

    The alternative I see is to create the destination bitmap, then create a Graphics from it, set up its coordinate transformation matrix as needed and draw the source bitmap onto the Grahics.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Jun 2012
    Posts
    15

    Re: Rotating the picturebox image.

    Thanks for your reply.

    Actually i couldn't get the code working, from the msdn site, the one with the 90 degree increments. The compiler showed error at
    Code:
     PictureBox1->SizeMode = PictureBoxSizeMode::AutoSize;
    I tried commenting out this code, and it compiled successfully, but the image didn't rotate on button click.

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,583

    Re: Rotating the picturebox image.

    You didn't quote the error message you got for the code line you quoted, so I can only guess at the reason why you got it. Perhaps you're missing a using directive for the required namespace? At any rate, I don't think omitting the line would modify the behavior of the sample code in a "doesn't rotate" kinda way.

    I don't have that music.bmp file, so I can't tell what it looks like, but note this: The rotation by 180 degrees plus vertical flip that the sample code performs, effectively is the same as no rotation plus a horizontal flip. So if the image this is applied to is (close to) symmetrical to its vertical axis, the observable result of te operation will be (close to) none. (However, if the former actually applies to the image originally intended to be used with the sample code by MS, it actually is a rather poor sample...)
    Last edited by Eri523; September 6th, 2012 at 11:28 AM.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center