 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
kronos Guest
|
Posted: Tue Feb 13, 2007 3:41 pm Post subject: Is there a quick method to rotate an image? |
|
|
To rotate an image i use the following code, but it's too slow!
I don't know the OpenGL library but by chance do i have to look for there?
many thanks in advance!
/* ***************************************
void TForm1::TestRotate(Graphics::TBitmap *bmp_image)
{
int *ptr, *ptr_rotate;
// create bitmap temporary object
Graphics::TBitmap *bmp = new Graphics::TBitmap;
Graphics::TBitmap *bmp_rotate = new Graphics::TBitmap;
// load image
bmp->Assign(bmp_image);
// set bmp_rotate object dimensions by bmp object dimension
bmp_rotate->Width = bmp->Height;
bmp_rotate->Height = bmp->Width;
for(int y = 0; y < bmp->Height; y++)
{
for(int x = 0; x < bmp->Width; x++)
{
// anticlockwise image rotate
bmp_rotate->Canvas->Pixels[y][x] =
bmp->Canvas->Pixels[(bmp->Width - 1) - x][y];
}
}
// save image
bmp_image->Width = bmp_rotate->Width;
bmp_image->Height = bmp_rotate->Height;
bmp_image->Assign(bmp_rotate);
// destroy bitmap temporary object
delete bmp_rotate;
delete bmp;
}
**************************************** */ |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Feb 13, 2007 3:45 pm Post subject: Re: Is there a quick method to rotate an image? |
|
|
"kronos" <jhdhjsd.sdhjhdssu (AT) sdhdjsh (DOT) dgh> wrote in message
news:45d187b4$1 (AT) newsgroups (DOT) borland.com...
| Quote: | To rotate an image i use the following code, but it's too slow!
|
That is because the Pixels property is very slow to begin with. Have
a look at the following article for faster alternatives:
How to rotate a bitmap
http://www.leunen.com/cbuilder/rotbmp.html
Gambit |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|