BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Is there a quick method to rotate an image?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics)
View previous topic :: View next topic  
Author Message
kronos
Guest





PostPosted: Tue Feb 13, 2007 3:41 pm    Post subject: Is there a quick method to rotate an image? Reply with quote



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





PostPosted: Tue Feb 13, 2007 3:45 pm    Post subject: Re: Is there a quick method to rotate an image? Reply with quote



"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.