|
-
September 30th, 2011, 03:35 AM
#1
Out of memory
Hello guys,
New riddle for you,
I am using a method to rotate images in a form.
Code:
private: System::Drawing::Image^ rotateImage(Image^ b, float angle)
{
//create a new empty bitmap to hold rotated image
Bitmap^ returnBitmap = gcnew Bitmap(b->Width, b->Height);
//make a graphics object from the empty bitmap
Graphics^ g = Graphics::FromImage(returnBitmap);
//move rotation point to center of image
g->TranslateTransform((float)b->Width / 2, (float)b->Height / 2);
//rotate
g->RotateTransform(angle);
//move image back
g->TranslateTransform(-(float)b->Width / 2, -(float)b->Height / 2);
//draw passed in image onto graphics object
g->DrawImage(b, 0, 0);
return returnBitmap;
}
and it goes good, but sometimes after some time running the program I get Out of Memory error in line
Code:
g->DrawImage(b, 0, 0);
Is this a disposal issue ? do you have any idea how to fix it ?
Thanks and best regards,
Smallbit
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|