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
Printable View
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
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.
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 atI tried commenting out this code, and it compiled successfully, but the image didn't rotate on button click.Code:PictureBox1->SizeMode = PictureBoxSizeMode::AutoSize;
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...)