Buggy Bitmap.Clone ??

  • Thread starter Thread starter KK
  • Start date Start date
K

KK

Hi Guru's
I'm making a Image viewer have a lasso loop functionality
for zooming a particular section of image.
The picturebox contains a given image and using the mouse
the user draws a rectangle on the picturebox the
corresponding co-ordinates are cut out from the image and
strechted on the picturebox. This is fine for the 1st
time but when I want to store the new piece of image
using the Bitmap.Clone

m_ImgCopy = m_Img.Clone(new Rectangle(X,Y,iWidth,iHt),
m_Img.PixelFormat);

Cloning gives "Out of memory" exception for any X,Y > 0
co-ordinates, height and width do not spill over the
bounds.


Any other way of creating a copy for part of the original
image? Pls Help

TIA
KK
 
I tried this code and it wotked fine on .NET Framework 1.1 with Visual
Studio.NET 2003. Is that what you are using? You may have to include a code
snippet to see exactly what is going on. Of course you will get
Outofmemoryexception if you do go over the bounds

Bitmap myBitmap = new Bitmap("test.jpg");
// Clone a portion of the Bitmap object.
RectangleF cloneRect = new RectangleF(10, 10, 12, 12);
System.Drawing.Imaging.PixelFormat format = myBitmap.PixelFormat;
Bitmap cloneBitmap = myBitmap.Clone(cloneRect, format);

Andy Mortimer [MS]
Please do not send email directly to this alias. This alias is for
newsgroup purposes only

This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm"
 
Back
Top