Watch, Follow, &
Connect with Us

Developer Tools Community.

Welcome, Guest
Guest Settings

Replies: 2 - Last Post: Feb 25, 2016 1:16 PM Last Post By: Goran Ekstrom
 Posts: 153 Registered: 11/12/01
 rotate by angle Posted: Dec 7, 2015 2:27 AM Hi, How to I rotate a .JPG image on a Canvas by angle or 90cw or ccw ? Thanks
 Posts: 12 Registered: 10/28/06
 Re: rotate by angle Posted: Feb 25, 2016 12:26 PM   in response to: Alain Bastien Alain Bastien wrote: Hi, How to I rotate a .JPG image on a Canvas by angle or 90cw or ccw ? Thanks I dont know libraries doing that work, but Im sure they exist, in some place. If you prefer to do it yourself, you could: 1) load the images in a Graphics::TBitmap structure; 2) access the pixels colors through the ScanLine method: `````` for (int y = 0; y < myBitmap->Height; ++y) { RGBQUAD* const pRow = static_cast (myBitmap ->ScanLine[y]); for (int x = 0; x < myBitmap->Width; ++x) { int redValue = pRowOut[x].rgbRed; int greenValue = pRowOut[x].rgbGreen; int blueValue = pRowOut[x].rgbBlue; } } `````` 3) manipulate the pixels with a rotation matrix algorythm (you can rotate 90 and flip by inverting rows and columns) 4) recreate the modified TBitmap: Edited by: Mario Sassone on Feb 25, 2016 9:26 PM Edited by: Mario Sassone on Feb 25, 2016 9:27 PM
 Posts: 149 Registered: 1/10/04
 Re: rotate by angle Posted: Feb 25, 2016 1:16 PM   in response to: Alain Bastien Alain Bastien wrote: Hi, How to I rotate a .JPG image on a Canvas by angle or 90cw or ccw ? Thanks Maybe some of these links may help: http://www.codeguru.com/cpp/g-m/bitmap/specialeffects/article.php/c1743/Rotate-a-bitmap-image.htm https://msdn.microsoft.com/en-us/library/windows/desktop/dd183389(v=vs.85).aspx Google "winapi rotate bitmap" for more info.
Legend