How to Clip a portion of an Image

A

Anand Ganesh

HI All,

I have an Image. I want to clip a portion of it and copy to another image.
How to do this? I know the bounding rectangle to clip.

Any suggestions please.

Thanks for your time and help.

Regards
Anand Ganesh
 
J

Jonathan Schafer

Create a graphics object from a bitmap and draw into it using the
image from the other graphics object. You can specify the source and
dest rects.

Jonathan Schafer
 
A

Anand Ganesh

I tried this but I got an error


An unhandled exception of type 'System.Exception' occurred in
system.drawing.dll

Additional information: A Graphics object cannot be created from an image
that has an indexed pixel format.


But the problem is after clipping I need another Image object itself. The
destination should be an image but the imae should be a clipped image of the
bigger Image.

Any more suggestions please?

Regards
Anand Ganesh
 
J

Jonathan Schafer

The following code works for me. It loads a .gif, draws the 30 x 30
section of the gif into an offscreen bitmap, and then draws the scaled
image into a picturebox.

System.Drawing.Bitmap bmp = new Bitmap(30, 30);
Image
img=System.Drawing.Image.FromFile(@"C:\cygwin\bin\openssl-0.9.6d\doc\openssl_button.gif");
Graphics g1 = pictureBox1.CreateGraphics();
g1.DrawImage(img, 0, 0, img.Width, img.Height);
g1.Dispose();
Graphics g3 = Graphics.FromImage(bmp);
g3.DrawImageUnscaled(img, 0, 0, bmp.Width, bmp.Height);
Graphics g2 = pictureBox2.CreateGraphics();
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height);
g2.Dispose();
g3.Dispose();
bmp.Dispose();
img.Dispose();


Jonathan Schafer
 
A

Anand Ganesh

Hi,

See you have a .gif image. I have .tif image. May be that is the problem.
Also I am not sure how to get another image itself; instead of drawing to
the user, I should get a portion of the image and save in a file.

Regards
Anand Ganesh
 
J

Jonathan Schafer

Shouldn't matter. A gif file is a 256 color palette indexed image. I
only used it to show that using indexed images works.

Maybe you could post a sample of your code to see what you doing.

Jonathan Schafer
 
J

Jonathan Schafer

I've given you the sample code that does just that. It loads a gif
file, copies a 30 x 30 portion ( rect(0, 0, 29, 29) of the original
into the new bitmap, and draws both to a picturebox to ensure that I
am cropping the image correctly.

What more do you want?

Jonathan Schafer
 
C

Chris Hornberger

For you to write it, of course!! Now aren't you silly?

Sorry to be cranky... I've been arguing with people all day about
self-motivation and the idea of "helping those who help themselves".
 
A

Anand Ganesh

Hi ,

I am sorry if I am troubling you or may be I am having difficulty
understanding the code.


Here is your code and my understanding

System.Drawing.Bitmap bmp = new Bitmap(30, 30); [ Creates an
empty bmp of size 30 x 30 ]
Image
img=System.Drawing.Image.FromFile(@"C:\cygwin\bin\openssl-0.9.6d\doc\openssl
_button.gif"); [ Creates an Image Object ]
Graphics g1 = pictureBox1.CreateGraphics();
[ Creates a Graphics Object ]
g1.DrawImage(img, 0, 0, img.Width, img.Height);
[ Draws the Img in the pictureBox1 using the Graphics g1 with full Img width
and height]
g1.Dispose();
[Disposed g1]
Graphics g3 = Graphics.FromImage(bmp);
[Creating another Graphics from the Empty Bitmap 30x30]
g3.DrawImageUnscaled(img, 0, 0, bmp.Width, bmp.Height); [Drawing the
unscaled image of Img also extracting the specified 30x30 portion from the
img ] [Is the clipping occurring here?]
Graphics g2 = pictureBox2.CreateGraphics();
[creating g2]
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height); [Drawing the bmp
in the picturebox]
g2.Dispose();
[From here below all are disposed]
g3.Dispose();
bmp.Dispose();
img.Dispose();

Here is my code. All I am doing is trying to clip a portion and copy to
clipboard, it is exactly same as yours. But it doesn't work.

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;



Can you tell me am I missing something here?



I really wish this will be a great lesson for me which I will not forget in
my lifetime if you could say what I am missing.



Thanks for spending your precious time to teach Newbie like me.

Regards

Anand Ganesh
 
A

Anand Ganesh

It is not throwing Exception but I am expecting it will copy the clipped
image into a Clipboard, which it is not doing. I am really surprised.

This is such a simple issue to copy a portion of the image to clipboard and
I am not able to do.

I am really glad I have a friend who is helping me out.

This is an Image Control I am writing. This has a toolbar and few buttons.
All the buttons are working fine except the code for this "Copy" button.

Once the user zooms in to the portion of the image and when he clicks copy,
I want that zoomed portion of the image to be transfered to the clipboard.

Here is the code after the user clicks the button.

The ImageRect is a RectangleF object and I am manipulating its values as and
when the user zooms in or zooms out or pan. Then applying this ImageRect on
the original image so that the right portion of the image is drawn for the
user.

TheImage to draw is an Image Object, which has the original image.

The test image I am using has a dimension of 3592 x 2485. It is a .tif image
file.

private void toolBarIB_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

this.Current_ToolName = e.Button.Text ;

if (e.Button.Text == "FZoomIn")

{

float WidthFactor = ImageRect.Width / 5 ;

float HeightFactor = ImageRect.Height / 5 ;

ImageRect.X = ImageRect.X + WidthFactor ;

ImageRect.Y = ImageRect.Y + HeightFactor ;

ImageRect.Width = ImageRect.Width - (2 * WidthFactor) ;

ImageRect.Height = ImageRect.Height - (2 * HeightFactor) ;

this.Cursor = System.Windows.Forms.Cursors.Default ;

Invalidate() ;

}

else if (e.Button.Text == "FZoomOut")

{

float WidthFactor = ImageRect.Width / 5 ;

float HeightFactor = ImageRect.Height / 5 ;

ImageRect.X = ImageRect.X - WidthFactor ;

ImageRect.Y = ImageRect.Y - HeightFactor ;

ImageRect.Width = ImageRect.Width + (2 * WidthFactor) ;

ImageRect.Height = ImageRect.Height + (2 * HeightFactor) ;

this.Cursor = System.Windows.Forms.Cursors.Default ;

Invalidate() ;

}

else if (e.Button.Text == "Pan")

{

this.Cursor = new Cursor(this.GetType(), "HandCursor.cur");

}

else if (e.Button.Text == "FullExtent")

{

this.ImageRect = this.Initial_ImageRect ;

Invalidate() ;

}

else if (e.Button.Text == "ZoomIn")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

else if (e.Button.Text == "ZoomOut")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

else if (e.Button.Text == "Copy")

{

try

{

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;

}

catch(Exception ex)

{

MessageBox.Show(ex.Message) ;

}

}

else if (e.Button.Text == "Measure")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

}


Jonathan Schafer said:
See embedded comments below:

Jonathan Schafer

Hi ,

I am sorry if I am troubling you or may be I am having difficulty
understanding the code.


Here is your code and my understanding

System.Drawing.Bitmap bmp = new Bitmap(30, 30); [ Creates an
empty bmp of size 30 x 30 ]
Image
img=System.Drawing.Image.FromFile(@"C:\cygwin\bin\openssl-0.9.6d\doc\openss
l
_button.gif"); [ Creates an Image Object ]
Graphics g1 = pictureBox1.CreateGraphics();
[ Creates a Graphics Object ]
g1.DrawImage(img, 0, 0, img.Width, img.Height);
[ Draws the Img in the pictureBox1 using the Graphics g1 with full Img width
and height]
g1.Dispose();
[Disposed g1]
Graphics g3 = Graphics.FromImage(bmp);
[Creating another Graphics from the Empty Bitmap 30x30]
g3.DrawImageUnscaled(img, 0, 0, bmp.Width, bmp.Height); [Drawing the
unscaled image of Img also extracting the specified 30x30 portion from the
img ] [Is the clipping occurring here?]
Graphics g2 = pictureBox2.CreateGraphics();
[creating g2]
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height); [Drawing the bmp
in the picturebox]
g2.Dispose();
[From here below all are disposed]
g3.Dispose();
bmp.Dispose();
img.Dispose();

Your comments regarding the code above are correct. The clipping
occurs on g3.DrawImageUnscaled. What I've done is created a 30 x 30
rectangle of the original bitmap and copied it into a second bitmap,
thus clipping the rest of the bitmap off.
Here is my code. All I am doing is trying to clip a portion and copy to
clipboard, it is exactly same as yours. But it doesn't work.

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;



Can you tell me am I missing something here?

So far as I can tell, this looks correct. What part doesn't work?
Are you getting an exception? If so, what is the exception and on
which line does it occur?

If you aren't getting an exception but the result is incorrect, what
part is incorrect.

If your image is small, perhaps you code attach a .zip file with the
image and your .cs file containing only the code necessary to crop the
bitmap and I could look at it in a project here.
I really wish this will be a great lesson for me which I will not forget in
my lifetime if you could say what I am missing.



Thanks for spending your precious time to teach Newbie like me.

Regards

Anand Ganesh






drawing
to s
s
 
A

Anand Ganesh

It is not throwing Exception but I am expecting it will copy the clipped
image into a Clipboard, which it is not doing. I am really surprised.

This is such a simple issue to copy a portion of the image to clipboard and
I am not able to do.

I am really glad I have a friend who is helping me out.

This is an Image Control I am writing. This has a toolbar and few buttons.
All the buttons are working fine except the code for this "Copy" button.

Once the user zooms in to the portion of the image and when he clicks copy,
I want that zoomed portion of the image to be transfered to the clipboard.

Here is the code after the user clicks the button.

The ImageRect is a RectangleF object and I am manipulating its values as and
when the user zooms in or zooms out or pan. Then applying this ImageRect on
the original image so that the right portion of the image is drawn for the
user.

TheImage to draw is an Image Object, which has the original image.

The test image I am using has a dimension of 3592 x 2485. It is a .tif image
file.

private void toolBarIB_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

this.Current_ToolName = e.Button.Text ;

if (e.Button.Text == "FZoomIn")

{

float WidthFactor = ImageRect.Width / 5 ;

float HeightFactor = ImageRect.Height / 5 ;

ImageRect.X = ImageRect.X + WidthFactor ;

ImageRect.Y = ImageRect.Y + HeightFactor ;

ImageRect.Width = ImageRect.Width - (2 * WidthFactor) ;

ImageRect.Height = ImageRect.Height - (2 * HeightFactor) ;

this.Cursor = System.Windows.Forms.Cursors.Default ;

Invalidate() ;

}

else if (e.Button.Text == "FZoomOut")

{

float WidthFactor = ImageRect.Width / 5 ;

float HeightFactor = ImageRect.Height / 5 ;

ImageRect.X = ImageRect.X - WidthFactor ;

ImageRect.Y = ImageRect.Y - HeightFactor ;

ImageRect.Width = ImageRect.Width + (2 * WidthFactor) ;

ImageRect.Height = ImageRect.Height + (2 * HeightFactor) ;

this.Cursor = System.Windows.Forms.Cursors.Default ;

Invalidate() ;

}

else if (e.Button.Text == "Pan")

{

this.Cursor = new Cursor(this.GetType(), "HandCursor.cur");

}

else if (e.Button.Text == "FullExtent")

{

this.ImageRect = this.Initial_ImageRect ;

Invalidate() ;

}

else if (e.Button.Text == "ZoomIn")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

else if (e.Button.Text == "ZoomOut")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

else if (e.Button.Text == "Copy")

{

try

{

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;

}

catch(Exception ex)

{

MessageBox.Show(ex.Message) ;

}

}

else if (e.Button.Text == "Measure")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

}

Jonathan Schafer said:
See embedded comments below:

Jonathan Schafer

Hi ,

I am sorry if I am troubling you or may be I am having difficulty
understanding the code.


Here is your code and my understanding

System.Drawing.Bitmap bmp = new Bitmap(30, 30); [ Creates an
empty bmp of size 30 x 30 ]
Image
img=System.Drawing.Image.FromFile(@"C:\cygwin\bin\openssl-0.9.6d\doc\openss
l
_button.gif"); [ Creates an Image Object ]
Graphics g1 = pictureBox1.CreateGraphics();
[ Creates a Graphics Object ]
g1.DrawImage(img, 0, 0, img.Width, img.Height);
[ Draws the Img in the pictureBox1 using the Graphics g1 with full Img width
and height]
g1.Dispose();
[Disposed g1]
Graphics g3 = Graphics.FromImage(bmp);
[Creating another Graphics from the Empty Bitmap 30x30]
g3.DrawImageUnscaled(img, 0, 0, bmp.Width, bmp.Height); [Drawing the
unscaled image of Img also extracting the specified 30x30 portion from the
img ] [Is the clipping occurring here?]
Graphics g2 = pictureBox2.CreateGraphics();
[creating g2]
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height); [Drawing the bmp
in the picturebox]
g2.Dispose();
[From here below all are disposed]
g3.Dispose();
bmp.Dispose();
img.Dispose();

Your comments regarding the code above are correct. The clipping
occurs on g3.DrawImageUnscaled. What I've done is created a 30 x 30
rectangle of the original bitmap and copied it into a second bitmap,
thus clipping the rest of the bitmap off.
Here is my code. All I am doing is trying to clip a portion and copy to
clipboard, it is exactly same as yours. But it doesn't work.

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;



Can you tell me am I missing something here?

So far as I can tell, this looks correct. What part doesn't work?
Are you getting an exception? If so, what is the exception and on
which line does it occur?

If you aren't getting an exception but the result is incorrect, what
part is incorrect.

If your image is small, perhaps you code attach a .zip file with the
image and your .cs file containing only the code necessary to crop the
bitmap and I could look at it in a project here.
I really wish this will be a great lesson for me which I will not forget in
my lifetime if you could say what I am missing.



Thanks for spending your precious time to teach Newbie like me.

Regards

Anand Ganesh






drawing
to s
s
 
J

Jonathan Schafer

I really don't see anything wrong with the code. A couple of things
you can do...

1. Can you draw the cropped image onto a window or picturebox to see
if the image is in the cropped bitmap and is correct.

2. Is your application still running when you are looking at the
contents of the clipboard? The reason I ask is that you are not
specifying to retain the data in the clipboard when your application
exits (the overloaded method takes two parameters, the second a bool
indicating whether to keep the data in the clipboard when the app
exits.

Jonathan Schafer

It is not throwing Exception but I am expecting it will copy the clipped
image into a Clipboard, which it is not doing. I am really surprised.

This is such a simple issue to copy a portion of the image to clipboard and
I am not able to do.

I am really glad I have a friend who is helping me out.

This is an Image Control I am writing. This has a toolbar and few buttons.
All the buttons are working fine except the code for this "Copy" button.

Once the user zooms in to the portion of the image and when he clicks copy,
I want that zoomed portion of the image to be transfered to the clipboard.

Here is the code after the user clicks the button.

The ImageRect is a RectangleF object and I am manipulating its values as and
when the user zooms in or zooms out or pan. Then applying this ImageRect on
the original image so that the right portion of the image is drawn for the
user.

TheImage to draw is an Image Object, which has the original image.

The test image I am using has a dimension of 3592 x 2485. It is a .tif image
file.

private void toolBarIB_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

this.Current_ToolName = e.Button.Text ;

if (e.Button.Text == "FZoomIn")

{

float WidthFactor = ImageRect.Width / 5 ;

float HeightFactor = ImageRect.Height / 5 ;

ImageRect.X = ImageRect.X + WidthFactor ;

ImageRect.Y = ImageRect.Y + HeightFactor ;

ImageRect.Width = ImageRect.Width - (2 * WidthFactor) ;

ImageRect.Height = ImageRect.Height - (2 * HeightFactor) ;

this.Cursor = System.Windows.Forms.Cursors.Default ;

Invalidate() ;

}

else if (e.Button.Text == "FZoomOut")

{

float WidthFactor = ImageRect.Width / 5 ;

float HeightFactor = ImageRect.Height / 5 ;

ImageRect.X = ImageRect.X - WidthFactor ;

ImageRect.Y = ImageRect.Y - HeightFactor ;

ImageRect.Width = ImageRect.Width + (2 * WidthFactor) ;

ImageRect.Height = ImageRect.Height + (2 * HeightFactor) ;

this.Cursor = System.Windows.Forms.Cursors.Default ;

Invalidate() ;

}

else if (e.Button.Text == "Pan")

{

this.Cursor = new Cursor(this.GetType(), "HandCursor.cur");

}

else if (e.Button.Text == "FullExtent")

{

this.ImageRect = this.Initial_ImageRect ;

Invalidate() ;

}

else if (e.Button.Text == "ZoomIn")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

else if (e.Button.Text == "ZoomOut")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

else if (e.Button.Text == "Copy")

{

try

{

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;

}

catch(Exception ex)

{

MessageBox.Show(ex.Message) ;

}

}

else if (e.Button.Text == "Measure")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

}

Jonathan Schafer said:
See embedded comments below:

Jonathan Schafer

Hi ,

I am sorry if I am troubling you or may be I am having difficulty
understanding the code.


Here is your code and my understanding

System.Drawing.Bitmap bmp = new Bitmap(30, 30); [ Creates an
empty bmp of size 30 x 30 ]
Image
img=System.Drawing.Image.FromFile(@"C:\cygwin\bin\openssl-0.9.6d\doc\openss
l
_button.gif"); [ Creates an Image Object ]
Graphics g1 = pictureBox1.CreateGraphics();
[ Creates a Graphics Object ]
g1.DrawImage(img, 0, 0, img.Width, img.Height);
[ Draws the Img in the pictureBox1 using the Graphics g1 with full Img width
and height]
g1.Dispose();
[Disposed g1]
Graphics g3 = Graphics.FromImage(bmp);
[Creating another Graphics from the Empty Bitmap 30x30]
g3.DrawImageUnscaled(img, 0, 0, bmp.Width, bmp.Height); [Drawing the
unscaled image of Img also extracting the specified 30x30 portion from the
img ] [Is the clipping occurring here?]
Graphics g2 = pictureBox2.CreateGraphics();
[creating g2]
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height); [Drawing the bmp
in the picturebox]
g2.Dispose();
[From here below all are disposed]
g3.Dispose();
bmp.Dispose();
img.Dispose();

Your comments regarding the code above are correct. The clipping
occurs on g3.DrawImageUnscaled. What I've done is created a 30 x 30
rectangle of the original bitmap and copied it into a second bitmap,
thus clipping the rest of the bitmap off.
Here is my code. All I am doing is trying to clip a portion and copy to
clipboard, it is exactly same as yours. But it doesn't work.

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;



Can you tell me am I missing something here?

So far as I can tell, this looks correct. What part doesn't work?
Are you getting an exception? If so, what is the exception and on
which line does it occur?

If you aren't getting an exception but the result is incorrect, what
part is incorrect.

If your image is small, perhaps you code attach a .zip file with the
image and your .cs file containing only the code necessary to crop the
bitmap and I could look at it in a project here.
I really wish this will be a great lesson for me which I will not forget in
my lifetime if you could say what I am missing.



Thanks for spending your precious time to teach Newbie like me.

Regards

Anand Ganesh






I've given you the sample code that does just that. It loads a gif
file, copies a 30 x 30 portion ( rect(0, 0, 29, 29) of the original
into the new bitmap, and draws both to a picturebox to ensure that I
am cropping the image correctly.

What more do you want?

Jonathan Schafer


On Mon, 14 Jul 2003 10:42:11 -0700, "Anand Ganesh"

I don't have a code yet. This is what I wanted to do. Create a small
clipped
image from a bigger image and found there is no easy way and I need some
help.

Any suggestions please?

Shouldn't matter. A gif file is a 256 color palette indexed image. I
only used it to show that using indexed images works.

Maybe you could post a sample of your code to see what you doing.

Jonathan Schafer



On Mon, 14 Jul 2003 09:11:54 -0700, "Anand Ganesh"

Hi,

See you have a .gif image. I have .tif image. May be that is the
problem.
Also I am not sure how to get another image itself; instead of drawing
to
the user, I should get a portion of the image and save in a file.

Regards
Anand Ganesh

message
The following code works for me. It loads a .gif, draws the 30 x 30
section of the gif into an offscreen bitmap, and then draws the
scaled
image into a picturebox.

System.Drawing.Bitmap bmp = new Bitmap(30, 30);
Image
img=System.Drawing.Image.FromFile(@"C:\cygwin\bin\openssl-0.9.6d\doc\open s
s
l
_button.gif");
Graphics g1 = pictureBox1.CreateGraphics();
g1.DrawImage(img, 0, 0, img.Width, img.Height);
g1.Dispose();
Graphics g3 = Graphics.FromImage(bmp);
g3.DrawImageUnscaled(img, 0, 0, bmp.Width, bmp.Height);
Graphics g2 = pictureBox2.CreateGraphics();
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height);
g2.Dispose();
g3.Dispose();
bmp.Dispose();
img.Dispose();


Jonathan Schafer

On Sun, 13 Jul 2003 21:53:20 -0700, "Anand Ganesh"

I tried this but I got an error


An unhandled exception of type 'System.Exception' occurred in
system.drawing.dll

Additional information: A Graphics object cannot be created from an
image
that has an indexed pixel format.


But the problem is after clipping I need another Image object
itself.
The
destination should be an image but the imae should be a clipped
image
of
the
bigger Image.

Any more suggestions please?

Regards
Anand Ganesh


message
Create a graphics object from a bitmap and draw into it using the
image from the other graphics object. You can specify the source
and
dest rects.

Jonathan Schafer

On Fri, 11 Jul 2003 18:49:11 -0700, "Anand Ganesh"

HI All,

I have an Image. I want to clip a portion of it and copy to
another
image.
How to do this? I know the bounding rectangle to clip.

Any suggestions please.

Thanks for your time and help.

Regards
Anand Ganesh
 
A

Anand Ganesh

1. I tried to draw the clipped bmp in a picture box. Nothing shows up. Which
means it is empty.

[

Here is where I strongly belive in the First place the Image is not clipped.
The reason is as follows

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height) ; [This is an Empty Image]
Graphics Gra = Graphics.FromImage(TheClippedBmp) ;
[Graphics Object derived from empty image]
Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height) ; [A portion of
the original image is drawn on the Graphics object. So no clipping has taken
place.]

Clipping is not happening anywhere in the above steps.

]

2. Yes my application is still running, I am not exiting it after placing
the clipped image in the clipboard.

So I hope now you can understand my problem.



Jonathan Schafer said:
I really don't see anything wrong with the code. A couple of things
you can do...

1. Can you draw the cropped image onto a window or picturebox to see
if the image is in the cropped bitmap and is correct.

2. Is your application still running when you are looking at the
contents of the clipboard? The reason I ask is that you are not
specifying to retain the data in the clipboard when your application
exits (the overloaded method takes two parameters, the second a bool
indicating whether to keep the data in the clipboard when the app
exits.

Jonathan Schafer

It is not throwing Exception but I am expecting it will copy the clipped
image into a Clipboard, which it is not doing. I am really surprised.

This is such a simple issue to copy a portion of the image to clipboard and
I am not able to do.

I am really glad I have a friend who is helping me out.

This is an Image Control I am writing. This has a toolbar and few buttons.
All the buttons are working fine except the code for this "Copy" button.

Once the user zooms in to the portion of the image and when he clicks copy,
I want that zoomed portion of the image to be transfered to the clipboard.

Here is the code after the user clicks the button.

The ImageRect is a RectangleF object and I am manipulating its values as and
when the user zooms in or zooms out or pan. Then applying this ImageRect on
the original image so that the right portion of the image is drawn for the
user.

TheImage to draw is an Image Object, which has the original image.

The test image I am using has a dimension of 3592 x 2485. It is a .tif image
file.

private void toolBarIB_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

this.Current_ToolName = e.Button.Text ;

if (e.Button.Text == "FZoomIn")

{

float WidthFactor = ImageRect.Width / 5 ;

float HeightFactor = ImageRect.Height / 5 ;

ImageRect.X = ImageRect.X + WidthFactor ;

ImageRect.Y = ImageRect.Y + HeightFactor ;

ImageRect.Width = ImageRect.Width - (2 * WidthFactor) ;

ImageRect.Height = ImageRect.Height - (2 * HeightFactor) ;

this.Cursor = System.Windows.Forms.Cursors.Default ;

Invalidate() ;

}

else if (e.Button.Text == "FZoomOut")

{

float WidthFactor = ImageRect.Width / 5 ;

float HeightFactor = ImageRect.Height / 5 ;

ImageRect.X = ImageRect.X - WidthFactor ;

ImageRect.Y = ImageRect.Y - HeightFactor ;

ImageRect.Width = ImageRect.Width + (2 * WidthFactor) ;

ImageRect.Height = ImageRect.Height + (2 * HeightFactor) ;

this.Cursor = System.Windows.Forms.Cursors.Default ;

Invalidate() ;

}

else if (e.Button.Text == "Pan")

{

this.Cursor = new Cursor(this.GetType(), "HandCursor.cur");

}

else if (e.Button.Text == "FullExtent")

{

this.ImageRect = this.Initial_ImageRect ;

Invalidate() ;

}

else if (e.Button.Text == "ZoomIn")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

else if (e.Button.Text == "ZoomOut")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

else if (e.Button.Text == "Copy")

{

try

{

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;

}

catch(Exception ex)

{

MessageBox.Show(ex.Message) ;

}

}

else if (e.Button.Text == "Measure")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

}

Jonathan Schafer said:
See embedded comments below:

Jonathan Schafer

On Mon, 14 Jul 2003 23:49:48 -0700, "Anand Ganesh"

Hi ,

I am sorry if I am troubling you or may be I am having difficulty
understanding the code.


Here is your code and my understanding

System.Drawing.Bitmap bmp = new Bitmap(30, 30); [ Creates an
empty bmp of size 30 x 30 ]
Image
img=System.Drawing.Image.FromFile(@"C:\cygwin\bin\openssl-0.9.6d\doc\opens s
l
_button.gif"); [ Creates an Image Object ]
Graphics g1 = pictureBox1.CreateGraphics();
[ Creates a Graphics Object ]
g1.DrawImage(img, 0, 0, img.Width, img.Height);
[ Draws the Img in the pictureBox1 using the Graphics g1 with full Img width
and height]
g1.Dispose();
[Disposed g1]
Graphics g3 = Graphics.FromImage(bmp);
[Creating another Graphics from the Empty Bitmap 30x30]
g3.DrawImageUnscaled(img, 0, 0, bmp.Width, bmp.Height); [Drawing the
unscaled image of Img also extracting the specified 30x30 portion from the
img ] [Is the clipping occurring here?]
Graphics g2 = pictureBox2.CreateGraphics();
[creating g2]
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height); [Drawing the bmp
in the picturebox]
g2.Dispose();
[From here below all are disposed]
g3.Dispose();
bmp.Dispose();
img.Dispose();


Your comments regarding the code above are correct. The clipping
occurs on g3.DrawImageUnscaled. What I've done is created a 30 x 30
rectangle of the original bitmap and copied it into a second bitmap,
thus clipping the rest of the bitmap off.

Here is my code. All I am doing is trying to clip a portion and copy to
clipboard, it is exactly same as yours. But it doesn't work.

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;



Can you tell me am I missing something here?


So far as I can tell, this looks correct. What part doesn't work?
Are you getting an exception? If so, what is the exception and on
which line does it occur?

If you aren't getting an exception but the result is incorrect, what
part is incorrect.

If your image is small, perhaps you code attach a .zip file with the
image and your .cs file containing only the code necessary to crop the
bitmap and I could look at it in a project here.


I really wish this will be a great lesson for me which I will not
forget
in
my lifetime if you could say what I am missing.



Thanks for spending your precious time to teach Newbie like me.

Regards

Anand Ganesh






I've given you the sample code that does just that. It loads a gif
file, copies a 30 x 30 portion ( rect(0, 0, 29, 29) of the original
into the new bitmap, and draws both to a picturebox to ensure that I
am cropping the image correctly.

What more do you want?

Jonathan Schafer


On Mon, 14 Jul 2003 10:42:11 -0700, "Anand Ganesh"

I don't have a code yet. This is what I wanted to do. Create a small
clipped
image from a bigger image and found there is no easy way and I need some
help.

Any suggestions please?

Shouldn't matter. A gif file is a 256 color palette indexed
image.
I
only used it to show that using indexed images works.

Maybe you could post a sample of your code to see what you doing.

Jonathan Schafer



On Mon, 14 Jul 2003 09:11:54 -0700, "Anand Ganesh"

Hi,

See you have a .gif image. I have .tif image. May be that is the
problem.
Also I am not sure how to get another image itself; instead of drawing
to
the user, I should get a portion of the image and save in a file.

Regards
Anand Ganesh

message
The following code works for me. It loads a .gif, draws the
30 x
30
section of the gif into an offscreen bitmap, and then draws the
scaled
image into a picturebox.

System.Drawing.Bitmap bmp = new Bitmap(30, 30);
Image




img=System.Drawing.Image.FromFile(@"C:\cygwin\bin\openssl-0.9.6d\doc\ope
n
s
s
l
_button.gif");
Graphics g1 = pictureBox1.CreateGraphics();
g1.DrawImage(img, 0, 0, img.Width, img.Height);
g1.Dispose();
Graphics g3 = Graphics.FromImage(bmp);
g3.DrawImageUnscaled(img, 0, 0, bmp.Width, bmp.Height);
Graphics g2 = pictureBox2.CreateGraphics();
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height);
g2.Dispose();
g3.Dispose();
bmp.Dispose();
img.Dispose();


Jonathan Schafer

On Sun, 13 Jul 2003 21:53:20 -0700, "Anand Ganesh"

I tried this but I got an error


An unhandled exception of type 'System.Exception' occurred in
system.drawing.dll

Additional information: A Graphics object cannot be created
from
an
image
that has an indexed pixel format.


But the problem is after clipping I need another Image object
itself.
The
destination should be an image but the imae should be a clipped
image
of
the
bigger Image.

Any more suggestions please?

Regards
Anand Ganesh


"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com>
wrote
in
message
Create a graphics object from a bitmap and draw into it
using
the
image from the other graphics object. You can specify the source
and
dest rects.

Jonathan Schafer

On Fri, 11 Jul 2003 18:49:11 -0700, "Anand Ganesh"

HI All,

I have an Image. I want to clip a portion of it and copy to
another
image.
How to do this? I know the bounding rectangle to clip.

Any suggestions please.

Thanks for your time and help.

Regards
Anand Ganesh
 
J

Jonathan Schafer

I was thinking about the clipping and the DrawImageUnscaled won't work
for you. The reason is while it will clip the image, it will always
draw from the 0,0 coordinate of the source image.

Here is the method you need...

Graphics.DrawImage(Image image, Rectangle destRect, Rectangle srcRect,
GraphicsUnit srcUnit);

This allows you to specify the coordinates of the portion of the image
you want to draw from.

So, the code would in fact look like this (more or less)...

Rectangle rect = ImageRect.Truncate();

System.Drawing.Bitmap TheClippedBmp = new Bitmap(rect.Width,
rect.Height) ;
Graphics Gra = Graphics.FromImage(TheClippedBmp) ;
Gra.DrawImage(this.TheImagetoDraw, new Rectangle(0, 0, rect.Width,
rect.Height), rect, GraphicsUnit.Pixel) ;

This should give you the clipped image because you specified with the
source rectangle the area of the original bitmap you want to copy.

Try this and let me know if it works.

Jonathan Schafer


1. I tried to draw the clipped bmp in a picture box. Nothing shows up. Which
means it is empty.

[

Here is where I strongly belive in the First place the Image is not clipped.
The reason is as follows

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height) ; [This is an Empty Image]
Graphics Gra = Graphics.FromImage(TheClippedBmp) ;
[Graphics Object derived from empty image]
Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height) ; [A portion of
the original image is drawn on the Graphics object. So no clipping has taken
place.]

Clipping is not happening anywhere in the above steps.

]

2. Yes my application is still running, I am not exiting it after placing
the clipped image in the clipboard.

So I hope now you can understand my problem.



Jonathan Schafer said:
I really don't see anything wrong with the code. A couple of things
you can do...

1. Can you draw the cropped image onto a window or picturebox to see
if the image is in the cropped bitmap and is correct.

2. Is your application still running when you are looking at the
contents of the clipboard? The reason I ask is that you are not
specifying to retain the data in the clipboard when your application
exits (the overloaded method takes two parameters, the second a bool
indicating whether to keep the data in the clipboard when the app
exits.

Jonathan Schafer

It is not throwing Exception but I am expecting it will copy the clipped
image into a Clipboard, which it is not doing. I am really surprised.

This is such a simple issue to copy a portion of the image to clipboard and
I am not able to do.

I am really glad I have a friend who is helping me out.

This is an Image Control I am writing. This has a toolbar and few buttons.
All the buttons are working fine except the code for this "Copy" button.

Once the user zooms in to the portion of the image and when he clicks copy,
I want that zoomed portion of the image to be transfered to the clipboard.

Here is the code after the user clicks the button.

The ImageRect is a RectangleF object and I am manipulating its values as and
when the user zooms in or zooms out or pan. Then applying this ImageRect on
the original image so that the right portion of the image is drawn for the
user.

TheImage to draw is an Image Object, which has the original image.

The test image I am using has a dimension of 3592 x 2485. It is a .tif image
file.

private void toolBarIB_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

this.Current_ToolName = e.Button.Text ;

if (e.Button.Text == "FZoomIn")

{

float WidthFactor = ImageRect.Width / 5 ;

float HeightFactor = ImageRect.Height / 5 ;

ImageRect.X = ImageRect.X + WidthFactor ;

ImageRect.Y = ImageRect.Y + HeightFactor ;

ImageRect.Width = ImageRect.Width - (2 * WidthFactor) ;

ImageRect.Height = ImageRect.Height - (2 * HeightFactor) ;

this.Cursor = System.Windows.Forms.Cursors.Default ;

Invalidate() ;

}

else if (e.Button.Text == "FZoomOut")

{

float WidthFactor = ImageRect.Width / 5 ;

float HeightFactor = ImageRect.Height / 5 ;

ImageRect.X = ImageRect.X - WidthFactor ;

ImageRect.Y = ImageRect.Y - HeightFactor ;

ImageRect.Width = ImageRect.Width + (2 * WidthFactor) ;

ImageRect.Height = ImageRect.Height + (2 * HeightFactor) ;

this.Cursor = System.Windows.Forms.Cursors.Default ;

Invalidate() ;

}

else if (e.Button.Text == "Pan")

{

this.Cursor = new Cursor(this.GetType(), "HandCursor.cur");

}

else if (e.Button.Text == "FullExtent")

{

this.ImageRect = this.Initial_ImageRect ;

Invalidate() ;

}

else if (e.Button.Text == "ZoomIn")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

else if (e.Button.Text == "ZoomOut")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

else if (e.Button.Text == "Copy")

{

try

{

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;

}

catch(Exception ex)

{

MessageBox.Show(ex.Message) ;

}

}

else if (e.Button.Text == "Measure")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

}

See embedded comments below:

Jonathan Schafer

On Mon, 14 Jul 2003 23:49:48 -0700, "Anand Ganesh"

Hi ,

I am sorry if I am troubling you or may be I am having difficulty
understanding the code.


Here is your code and my understanding

System.Drawing.Bitmap bmp = new Bitmap(30, 30); [ Creates an
empty bmp of size 30 x 30 ]
Image
img=System.Drawing.Image.FromFile(@"C:\cygwin\bin\openssl-0.9.6d\doc\opens s
l
_button.gif"); [ Creates an Image Object ]
Graphics g1 = pictureBox1.CreateGraphics();
[ Creates a Graphics Object ]
g1.DrawImage(img, 0, 0, img.Width, img.Height);
[ Draws the Img in the pictureBox1 using the Graphics g1 with full Img
width
and height]
g1.Dispose();
[Disposed g1]
Graphics g3 = Graphics.FromImage(bmp);
[Creating another Graphics from the Empty Bitmap 30x30]
g3.DrawImageUnscaled(img, 0, 0, bmp.Width, bmp.Height); [Drawing the
unscaled image of Img also extracting the specified 30x30 portion from
the
img ] [Is the clipping occurring here?]
Graphics g2 = pictureBox2.CreateGraphics();
[creating g2]
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height); [Drawing the
bmp
in the picturebox]
g2.Dispose();
[From here below all are disposed]
g3.Dispose();
bmp.Dispose();
img.Dispose();


Your comments regarding the code above are correct. The clipping
occurs on g3.DrawImageUnscaled. What I've done is created a 30 x 30
rectangle of the original bitmap and copied it into a second bitmap,
thus clipping the rest of the bitmap off.

Here is my code. All I am doing is trying to clip a portion and copy to
clipboard, it is exactly same as yours. But it doesn't work.

System.Drawing.Bitmap TheClippedBmp = new
Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;



Can you tell me am I missing something here?


So far as I can tell, this looks correct. What part doesn't work?
Are you getting an exception? If so, what is the exception and on
which line does it occur?

If you aren't getting an exception but the result is incorrect, what
part is incorrect.

If your image is small, perhaps you code attach a .zip file with the
image and your .cs file containing only the code necessary to crop the
bitmap and I could look at it in a project here.


I really wish this will be a great lesson for me which I will not forget
in
my lifetime if you could say what I am missing.



Thanks for spending your precious time to teach Newbie like me.

Regards

Anand Ganesh






I've given you the sample code that does just that. It loads a gif
file, copies a 30 x 30 portion ( rect(0, 0, 29, 29) of the original
into the new bitmap, and draws both to a picturebox to ensure that I
am cropping the image correctly.

What more do you want?

Jonathan Schafer


On Mon, 14 Jul 2003 10:42:11 -0700, "Anand Ganesh"

I don't have a code yet. This is what I wanted to do. Create a small
clipped
image from a bigger image and found there is no easy way and I need
some
help.

Any suggestions please?

message
Shouldn't matter. A gif file is a 256 color palette indexed image.
I
only used it to show that using indexed images works.

Maybe you could post a sample of your code to see what you doing.

Jonathan Schafer



On Mon, 14 Jul 2003 09:11:54 -0700, "Anand Ganesh"

Hi,

See you have a .gif image. I have .tif image. May be that is the
problem.
Also I am not sure how to get another image itself; instead of
drawing
to
the user, I should get a portion of the image and save in a file.

Regards
Anand Ganesh

message
The following code works for me. It loads a .gif, draws the 30 x
30
section of the gif into an offscreen bitmap, and then draws the
scaled
image into a picturebox.

System.Drawing.Bitmap bmp = new Bitmap(30, 30);
Image
img=System.Drawing.Image.FromFile(@"C:\cygwin\bin\openssl-0.9.6d\doc\ope n
s
s
l
_button.gif");
Graphics g1 = pictureBox1.CreateGraphics();
g1.DrawImage(img, 0, 0, img.Width, img.Height);
g1.Dispose();
Graphics g3 = Graphics.FromImage(bmp);
g3.DrawImageUnscaled(img, 0, 0, bmp.Width, bmp.Height);
Graphics g2 = pictureBox2.CreateGraphics();
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height);
g2.Dispose();
g3.Dispose();
bmp.Dispose();
img.Dispose();


Jonathan Schafer

On Sun, 13 Jul 2003 21:53:20 -0700, "Anand Ganesh"

I tried this but I got an error


An unhandled exception of type 'System.Exception' occurred in
system.drawing.dll

Additional information: A Graphics object cannot be created from
an
image
that has an indexed pixel format.


But the problem is after clipping I need another Image object
itself.
The
destination should be an image but the imae should be a clipped
image
of
the
bigger Image.

Any more suggestions please?

Regards
Anand Ganesh


in
message
Create a graphics object from a bitmap and draw into it using
the
image from the other graphics object. You can specify the
source
and
dest rects.

Jonathan Schafer

On Fri, 11 Jul 2003 18:49:11 -0700, "Anand Ganesh"

HI All,

I have an Image. I want to clip a portion of it and copy to
another
image.
How to do this? I know the bounding rectangle to clip.

Any suggestions please.

Thanks for your time and help.

Regards
Anand Ganesh
 
A

Anand Ganesh

Jonathan,

You are a Genius ! Yes it did work.

I am so excited.

Now I learned that applying Gra.DrawImage will draw over the Empty bitmap
file from which the Gra was derived.

I thank you so much for staying so long in the conversation wthout giving
up.

With kind regards
Anand Ganesh




Jonathan Schafer said:
I was thinking about the clipping and the DrawImageUnscaled won't work
for you. The reason is while it will clip the image, it will always
draw from the 0,0 coordinate of the source image.

Here is the method you need...

Graphics.DrawImage(Image image, Rectangle destRect, Rectangle srcRect,
GraphicsUnit srcUnit);

This allows you to specify the coordinates of the portion of the image
you want to draw from.

So, the code would in fact look like this (more or less)...

Rectangle rect = ImageRect.Truncate();

System.Drawing.Bitmap TheClippedBmp = new Bitmap(rect.Width,
rect.Height) ;
Graphics Gra = Graphics.FromImage(TheClippedBmp) ;
Gra.DrawImage(this.TheImagetoDraw, new Rectangle(0, 0, rect.Width,
rect.Height), rect, GraphicsUnit.Pixel) ;

This should give you the clipped image because you specified with the
source rectangle the area of the original bitmap you want to copy.

Try this and let me know if it works.

Jonathan Schafer


1. I tried to draw the clipped bmp in a picture box. Nothing shows up. Which
means it is empty.

[

Here is where I strongly belive in the First place the Image is not clipped.
The reason is as follows

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height) ; [This is an Empty Image]
Graphics Gra = Graphics.FromImage(TheClippedBmp) ;
[Graphics Object derived from empty image]
Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height) ; [A portion of
the original image is drawn on the Graphics object. So no clipping has taken
place.]

Clipping is not happening anywhere in the above steps.

]

2. Yes my application is still running, I am not exiting it after placing
the clipped image in the clipboard.

So I hope now you can understand my problem.



Jonathan Schafer said:
I really don't see anything wrong with the code. A couple of things
you can do...

1. Can you draw the cropped image onto a window or picturebox to see
if the image is in the cropped bitmap and is correct.

2. Is your application still running when you are looking at the
contents of the clipboard? The reason I ask is that you are not
specifying to retain the data in the clipboard when your application
exits (the overloaded method takes two parameters, the second a bool
indicating whether to keep the data in the clipboard when the app
exits.

Jonathan Schafer

On Tue, 15 Jul 2003 09:23:03 -0700, "Anand Ganesh"

It is not throwing Exception but I am expecting it will copy the clipped
image into a Clipboard, which it is not doing. I am really surprised.

This is such a simple issue to copy a portion of the image to
clipboard
and
I am not able to do.

I am really glad I have a friend who is helping me out.

This is an Image Control I am writing. This has a toolbar and few buttons.
All the buttons are working fine except the code for this "Copy" button.

Once the user zooms in to the portion of the image and when he clicks copy,
I want that zoomed portion of the image to be transfered to the clipboard.

Here is the code after the user clicks the button.

The ImageRect is a RectangleF object and I am manipulating its values
as
and
when the user zooms in or zooms out or pan. Then applying this
ImageRect
on
the original image so that the right portion of the image is drawn for the
user.

TheImage to draw is an Image Object, which has the original image.

The test image I am using has a dimension of 3592 x 2485. It is a .tif image
file.

private void toolBarIB_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

this.Current_ToolName = e.Button.Text ;

if (e.Button.Text == "FZoomIn")

{

float WidthFactor = ImageRect.Width / 5 ;

float HeightFactor = ImageRect.Height / 5 ;

ImageRect.X = ImageRect.X + WidthFactor ;

ImageRect.Y = ImageRect.Y + HeightFactor ;

ImageRect.Width = ImageRect.Width - (2 * WidthFactor) ;

ImageRect.Height = ImageRect.Height - (2 * HeightFactor) ;

this.Cursor = System.Windows.Forms.Cursors.Default ;

Invalidate() ;

}

else if (e.Button.Text == "FZoomOut")

{

float WidthFactor = ImageRect.Width / 5 ;

float HeightFactor = ImageRect.Height / 5 ;

ImageRect.X = ImageRect.X - WidthFactor ;

ImageRect.Y = ImageRect.Y - HeightFactor ;

ImageRect.Width = ImageRect.Width + (2 * WidthFactor) ;

ImageRect.Height = ImageRect.Height + (2 * HeightFactor) ;

this.Cursor = System.Windows.Forms.Cursors.Default ;

Invalidate() ;

}

else if (e.Button.Text == "Pan")

{

this.Cursor = new Cursor(this.GetType(), "HandCursor.cur");

}

else if (e.Button.Text == "FullExtent")

{

this.ImageRect = this.Initial_ImageRect ;

Invalidate() ;

}

else if (e.Button.Text == "ZoomIn")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

else if (e.Button.Text == "ZoomOut")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

else if (e.Button.Text == "Copy")

{

try

{

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;

}

catch(Exception ex)

{

MessageBox.Show(ex.Message) ;

}

}

else if (e.Button.Text == "Measure")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

}

See embedded comments below:

Jonathan Schafer

On Mon, 14 Jul 2003 23:49:48 -0700, "Anand Ganesh"

Hi ,

I am sorry if I am troubling you or may be I am having difficulty
understanding the code.


Here is your code and my understanding

System.Drawing.Bitmap bmp = new Bitmap(30, 30); [
Creates
an
empty bmp of size 30 x 30 ]
Image


img=System.Drawing.Image.FromFile(@"C:\cygwin\bin\openssl-0.9.6d\doc\open
s
s
l
_button.gif"); [ Creates an Image Object ]
Graphics g1 = pictureBox1.CreateGraphics();
[ Creates a Graphics Object ]
g1.DrawImage(img, 0, 0, img.Width, img.Height);
[ Draws the Img in the pictureBox1 using the Graphics g1 with full Img
width
and height]
g1.Dispose();
[Disposed g1]
Graphics g3 = Graphics.FromImage(bmp);
[Creating another Graphics from the Empty Bitmap 30x30]
g3.DrawImageUnscaled(img, 0, 0, bmp.Width, bmp.Height);
[Drawing
the
unscaled image of Img also extracting the specified 30x30 portion from
the
img ] [Is the clipping occurring here?]
Graphics g2 = pictureBox2.CreateGraphics();
[creating g2]
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height); [Drawing the
bmp
in the picturebox]
g2.Dispose();
[From here below all are disposed]
g3.Dispose();
bmp.Dispose();
img.Dispose();


Your comments regarding the code above are correct. The clipping
occurs on g3.DrawImageUnscaled. What I've done is created a 30 x 30
rectangle of the original bitmap and copied it into a second bitmap,
thus clipping the rest of the bitmap off.

Here is my code. All I am doing is trying to clip a portion and
copy
to
clipboard, it is exactly same as yours. But it doesn't work.

System.Drawing.Bitmap TheClippedBmp = new
Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;



Can you tell me am I missing something here?


So far as I can tell, this looks correct. What part doesn't work?
Are you getting an exception? If so, what is the exception and on
which line does it occur?

If you aren't getting an exception but the result is incorrect, what
part is incorrect.

If your image is small, perhaps you code attach a .zip file with the
image and your .cs file containing only the code necessary to crop the
bitmap and I could look at it in a project here.


I really wish this will be a great lesson for me which I will not forget
in
my lifetime if you could say what I am missing.



Thanks for spending your precious time to teach Newbie like me.

Regards

Anand Ganesh






I've given you the sample code that does just that. It loads a gif
file, copies a 30 x 30 portion ( rect(0, 0, 29, 29) of the original
into the new bitmap, and draws both to a picturebox to ensure that I
am cropping the image correctly.

What more do you want?

Jonathan Schafer


On Mon, 14 Jul 2003 10:42:11 -0700, "Anand Ganesh"

I don't have a code yet. This is what I wanted to do. Create a small
clipped
image from a bigger image and found there is no easy way and I need
some
help.

Any suggestions please?

message
Shouldn't matter. A gif file is a 256 color palette indexed image.
I
only used it to show that using indexed images works.

Maybe you could post a sample of your code to see what you doing.

Jonathan Schafer



On Mon, 14 Jul 2003 09:11:54 -0700, "Anand Ganesh"

Hi,

See you have a .gif image. I have .tif image. May be that is the
problem.
Also I am not sure how to get another image itself; instead of
drawing
to
the user, I should get a portion of the image and save in a file.

Regards
Anand Ganesh

"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com>
wrote
in
message
The following code works for me. It loads a .gif, draws
the
30 x
30
section of the gif into an offscreen bitmap, and then draws the
scaled
image into a picturebox.

System.Drawing.Bitmap bmp = new Bitmap(30, 30);
Image





img=System.Drawing.Image.FromFile(@"C:\cygwin\bin\openssl-0.9.6d\doc\op
e
n
s
s
l
_button.gif");
Graphics g1 = pictureBox1.CreateGraphics();
g1.DrawImage(img, 0, 0, img.Width, img.Height);
g1.Dispose();
Graphics g3 = Graphics.FromImage(bmp);
g3.DrawImageUnscaled(img, 0, 0, bmp.Width, bmp.Height);
Graphics g2 = pictureBox2.CreateGraphics();
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height);
g2.Dispose();
g3.Dispose();
bmp.Dispose();
img.Dispose();


Jonathan Schafer

On Sun, 13 Jul 2003 21:53:20 -0700, "Anand Ganesh"

I tried this but I got an error


An unhandled exception of type 'System.Exception' occurred in
system.drawing.dll

Additional information: A Graphics object cannot be
created
from
an
image
that has an indexed pixel format.


But the problem is after clipping I need another Image object
itself.
The
destination should be an image but the imae should be a clipped
image
of
the
bigger Image.

Any more suggestions please?

Regards
Anand Ganesh


in
message
Create a graphics object from a bitmap and draw into it using
the
image from the other graphics object. You can specify the
source
and
dest rects.

Jonathan Schafer

On Fri, 11 Jul 2003 18:49:11 -0700, "Anand Ganesh"

HI All,

I have an Image. I want to clip a portion of it and
copy
to
another
image.
How to do this? I know the bounding rectangle to clip.

Any suggestions please.

Thanks for your time and help.

Regards
Anand Ganesh
 
J

Jonathan Schafer

If I were a genius, I would have figured out what was wrong yesterday
and you would have already been past this :). Glad you got it
working.

Regards,

Jonathan Schafer


Jonathan,

You are a Genius ! Yes it did work.

I am so excited.

Now I learned that applying Gra.DrawImage will draw over the Empty bitmap
file from which the Gra was derived.

I thank you so much for staying so long in the conversation wthout giving
up.

With kind regards
Anand Ganesh




Jonathan Schafer said:
I was thinking about the clipping and the DrawImageUnscaled won't work
for you. The reason is while it will clip the image, it will always
draw from the 0,0 coordinate of the source image.

Here is the method you need...

Graphics.DrawImage(Image image, Rectangle destRect, Rectangle srcRect,
GraphicsUnit srcUnit);

This allows you to specify the coordinates of the portion of the image
you want to draw from.

So, the code would in fact look like this (more or less)...

Rectangle rect = ImageRect.Truncate();

System.Drawing.Bitmap TheClippedBmp = new Bitmap(rect.Width,
rect.Height) ;
Graphics Gra = Graphics.FromImage(TheClippedBmp) ;
Gra.DrawImage(this.TheImagetoDraw, new Rectangle(0, 0, rect.Width,
rect.Height), rect, GraphicsUnit.Pixel) ;

This should give you the clipped image because you specified with the
source rectangle the area of the original bitmap you want to copy.

Try this and let me know if it works.

Jonathan Schafer


1. I tried to draw the clipped bmp in a picture box. Nothing shows up. Which
means it is empty.

[

Here is where I strongly belive in the First place the Image is not clipped.
The reason is as follows

System.Drawing.Bitmap TheClippedBmp = new Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height) ; [This is an Empty Image]
Graphics Gra = Graphics.FromImage(TheClippedBmp) ;
[Graphics Object derived from empty image]
Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height) ; [A portion of
the original image is drawn on the Graphics object. So no clipping has taken
place.]

Clipping is not happening anywhere in the above steps.

]

2. Yes my application is still running, I am not exiting it after placing
the clipped image in the clipboard.

So I hope now you can understand my problem.



I really don't see anything wrong with the code. A couple of things
you can do...

1. Can you draw the cropped image onto a window or picturebox to see
if the image is in the cropped bitmap and is correct.

2. Is your application still running when you are looking at the
contents of the clipboard? The reason I ask is that you are not
specifying to retain the data in the clipboard when your application
exits (the overloaded method takes two parameters, the second a bool
indicating whether to keep the data in the clipboard when the app
exits.

Jonathan Schafer

On Tue, 15 Jul 2003 09:23:03 -0700, "Anand Ganesh"

It is not throwing Exception but I am expecting it will copy the clipped
image into a Clipboard, which it is not doing. I am really surprised.

This is such a simple issue to copy a portion of the image to clipboard
and
I am not able to do.

I am really glad I have a friend who is helping me out.

This is an Image Control I am writing. This has a toolbar and few
buttons.
All the buttons are working fine except the code for this "Copy" button.

Once the user zooms in to the portion of the image and when he clicks
copy,
I want that zoomed portion of the image to be transfered to the
clipboard.

Here is the code after the user clicks the button.

The ImageRect is a RectangleF object and I am manipulating its values as
and
when the user zooms in or zooms out or pan. Then applying this ImageRect
on
the original image so that the right portion of the image is drawn for
the
user.

TheImage to draw is an Image Object, which has the original image.

The test image I am using has a dimension of 3592 x 2485. It is a .tif
image
file.

private void toolBarIB_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArgs e)

{

this.Current_ToolName = e.Button.Text ;

if (e.Button.Text == "FZoomIn")

{

float WidthFactor = ImageRect.Width / 5 ;

float HeightFactor = ImageRect.Height / 5 ;

ImageRect.X = ImageRect.X + WidthFactor ;

ImageRect.Y = ImageRect.Y + HeightFactor ;

ImageRect.Width = ImageRect.Width - (2 * WidthFactor) ;

ImageRect.Height = ImageRect.Height - (2 * HeightFactor) ;

this.Cursor = System.Windows.Forms.Cursors.Default ;

Invalidate() ;

}

else if (e.Button.Text == "FZoomOut")

{

float WidthFactor = ImageRect.Width / 5 ;

float HeightFactor = ImageRect.Height / 5 ;

ImageRect.X = ImageRect.X - WidthFactor ;

ImageRect.Y = ImageRect.Y - HeightFactor ;

ImageRect.Width = ImageRect.Width + (2 * WidthFactor) ;

ImageRect.Height = ImageRect.Height + (2 * HeightFactor) ;

this.Cursor = System.Windows.Forms.Cursors.Default ;

Invalidate() ;

}

else if (e.Button.Text == "Pan")

{

this.Cursor = new Cursor(this.GetType(), "HandCursor.cur");

}

else if (e.Button.Text == "FullExtent")

{

this.ImageRect = this.Initial_ImageRect ;

Invalidate() ;

}

else if (e.Button.Text == "ZoomIn")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

else if (e.Button.Text == "ZoomOut")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

else if (e.Button.Text == "Copy")

{

try

{

System.Drawing.Bitmap TheClippedBmp = new
Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;

}

catch(Exception ex)

{

MessageBox.Show(ex.Message) ;

}

}

else if (e.Button.Text == "Measure")

{

this.Cursor = System.Windows.Forms.Cursors.Cross ;

}

}

See embedded comments below:

Jonathan Schafer

On Mon, 14 Jul 2003 23:49:48 -0700, "Anand Ganesh"

Hi ,

I am sorry if I am troubling you or may be I am having difficulty
understanding the code.


Here is your code and my understanding

System.Drawing.Bitmap bmp = new Bitmap(30, 30); [ Creates
an
empty bmp of size 30 x 30 ]
Image
img=System.Drawing.Image.FromFile(@"C:\cygwin\bin\openssl-0.9.6d\doc\open s
s
l
_button.gif"); [ Creates an Image Object ]
Graphics g1 = pictureBox1.CreateGraphics();
[ Creates a Graphics Object ]
g1.DrawImage(img, 0, 0, img.Width, img.Height);
[ Draws the Img in the pictureBox1 using the Graphics g1 with full Img
width
and height]
g1.Dispose();
[Disposed g1]
Graphics g3 = Graphics.FromImage(bmp);
[Creating another Graphics from the Empty Bitmap 30x30]
g3.DrawImageUnscaled(img, 0, 0, bmp.Width, bmp.Height); [Drawing
the
unscaled image of Img also extracting the specified 30x30 portion from
the
img ] [Is the clipping occurring here?]
Graphics g2 = pictureBox2.CreateGraphics();
[creating g2]
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height); [Drawing the
bmp
in the picturebox]
g2.Dispose();
[From here below all are disposed]
g3.Dispose();
bmp.Dispose();
img.Dispose();


Your comments regarding the code above are correct. The clipping
occurs on g3.DrawImageUnscaled. What I've done is created a 30 x 30
rectangle of the original bitmap and copied it into a second bitmap,
thus clipping the rest of the bitmap off.

Here is my code. All I am doing is trying to clip a portion and copy
to
clipboard, it is exactly same as yours. But it doesn't work.

System.Drawing.Bitmap TheClippedBmp = new
Bitmap((int)this.ImageRect.Width,
(int)this.ImageRect.Height);

Graphics Gra = Graphics.FromImage(TheClippedBmp);

Gra.DrawImageUnscaled(this.TheImagetoDraw, (int) ImageRect.X ,(int)
ImageRect.Y,(int) ImageRect.Width,(int) ImageRect.Height);

System.Windows.Forms.Clipboard.SetDataObject(TheClippedBmp) ;

Gra.Dispose() ;

TheClippedBmp.Dispose() ;

this.statusBarPanelIBMsg.Text = "Data copied successfully !" ;



Can you tell me am I missing something here?


So far as I can tell, this looks correct. What part doesn't work?
Are you getting an exception? If so, what is the exception and on
which line does it occur?

If you aren't getting an exception but the result is incorrect, what
part is incorrect.

If your image is small, perhaps you code attach a .zip file with the
image and your .cs file containing only the code necessary to crop the
bitmap and I could look at it in a project here.


I really wish this will be a great lesson for me which I will not
forget
in
my lifetime if you could say what I am missing.



Thanks for spending your precious time to teach Newbie like me.

Regards

Anand Ganesh






message
I've given you the sample code that does just that. It loads a gif
file, copies a 30 x 30 portion ( rect(0, 0, 29, 29) of the original
into the new bitmap, and draws both to a picturebox to ensure that I
am cropping the image correctly.

What more do you want?

Jonathan Schafer


On Mon, 14 Jul 2003 10:42:11 -0700, "Anand Ganesh"

I don't have a code yet. This is what I wanted to do. Create a
small
clipped
image from a bigger image and found there is no easy way and I need
some
help.

Any suggestions please?

message
Shouldn't matter. A gif file is a 256 color palette indexed
image.
I
only used it to show that using indexed images works.

Maybe you could post a sample of your code to see what you doing.

Jonathan Schafer



On Mon, 14 Jul 2003 09:11:54 -0700, "Anand Ganesh"

Hi,

See you have a .gif image. I have .tif image. May be that is the
problem.
Also I am not sure how to get another image itself; instead of
drawing
to
the user, I should get a portion of the image and save in a
file.

Regards
Anand Ganesh

in
message
The following code works for me. It loads a .gif, draws the
30 x
30
section of the gif into an offscreen bitmap, and then draws
the
scaled
image into a picturebox.

System.Drawing.Bitmap bmp = new Bitmap(30, 30);
Image
img=System.Drawing.Image.FromFile(@"C:\cygwin\bin\openssl-0.9.6d\doc\op e
n
s
s
l
_button.gif");
Graphics g1 = pictureBox1.CreateGraphics();
g1.DrawImage(img, 0, 0, img.Width, img.Height);
g1.Dispose();
Graphics g3 = Graphics.FromImage(bmp);
g3.DrawImageUnscaled(img, 0, 0, bmp.Width, bmp.Height);
Graphics g2 = pictureBox2.CreateGraphics();
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height);
g2.Dispose();
g3.Dispose();
bmp.Dispose();
img.Dispose();


Jonathan Schafer

On Sun, 13 Jul 2003 21:53:20 -0700, "Anand Ganesh"

I tried this but I got an error


An unhandled exception of type 'System.Exception' occurred in
system.drawing.dll

Additional information: A Graphics object cannot be created
from
an
image
that has an indexed pixel format.


But the problem is after clipping I need another Image object
itself.
The
destination should be an image but the imae should be a
clipped
image
of
the
bigger Image.

Any more suggestions please?

Regards
Anand Ganesh


"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com>
wrote
in
message
Create a graphics object from a bitmap and draw into it
using
the
image from the other graphics object. You can specify the
source
and
dest rects.

Jonathan Schafer

On Fri, 11 Jul 2003 18:49:11 -0700, "Anand Ganesh"

HI All,

I have an Image. I want to clip a portion of it and copy
to
another
image.
How to do this? I know the bounding rectangle to clip.

Any suggestions please.

Thanks for your time and help.

Regards
Anand Ganesh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top