By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,191 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

How to Clip a portion of an Image

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
15 Replies


P: n/a
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"
<an**********@hotmail.com> wrote:
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


Nov 13 '05 #2

P: n/a
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
news:q5********************************@4ax.com...
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"
<an**********@hotmail.com> wrote:
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

Nov 13 '05 #3

P: n/a
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

On Sun, 13 Jul 2003 21:53:20 -0700, "Anand Ganesh"
<an**********@hotmail.com> wrote:
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
news:q5********************************@4ax.com.. .
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"
<an**********@hotmail.com> wrote:
>HI All,
>
>I have an Image. I want to clip a portion of it and copy to anotherimage. >How to do this? I know the bounding rectangle to clip.
>
>Any suggestions please.
>
>Thanks for your time and help.
>
>Regards
>Anand Ganesh
>


Nov 13 '05 #4

P: n/a
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
news:e9********************************@4ax.com...
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

On Sun, 13 Jul 2003 21:53:20 -0700, "Anand Ganesh"
<an**********@hotmail.com> wrote:
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 thebigger Image.

Any more suggestions please?

Regards
Anand Ganesh
"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:q5********************************@4ax.com.. .
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"
<an**********@hotmail.com> wrote:

>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
>

Nov 13 '05 #5

P: n/a
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"
<an**********@hotmail.com> wrote:
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
news:e9********************************@4ax.com.. .
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

On Sun, 13 Jul 2003 21:53:20 -0700, "Anand Ganesh"
<an**********@hotmail.com> wrote:
>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 ofthe >bigger Image.
>
>Any more suggestions please?
>
>Regards
>Anand Ganesh
>
>
>"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
>news:q5********************************@4ax.com.. .
>> 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"
>> <an**********@hotmail.com> wrote:
>>
>> >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
>> >
>>
>


Nov 13 '05 #6

P: n/a
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"
<an**********@hotmail.com> wrote:
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?

"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:ac********************************@4ax.com.. .
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"
<an**********@hotmail.com> wrote:
>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
>news:e9********************************@4ax.com.. .
>> 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\bi n\openssl-0.9.6d\doc\openss

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"
>> <an**********@hotmail.com> wrote:
>>
>> >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 animage >> >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 imageof >the
>> >bigger Image.
>> >
>> >Any more suggestions please?
>> >
>> >Regards
>> >Anand Ganesh
>> >
>> >
>> >"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote inmessage >> >news:q5********************************@4ax.com.. .
>> >> Create a graphics object from a bitmap and draw into it using the
>> >> image from the other graphics object. You can specify the sourceand >> >> dest rects.
>> >>
>> >> Jonathan Schafer
>> >>
>> >> On Fri, 11 Jul 2003 18:49:11 -0700, "Anand Ganesh"
>> >> <an**********@hotmail.com> wrote:
>> >>
>> >> >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
>> >> >
>> >>
>> >
>>
>


Nov 13 '05 #7

P: n/a
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".

Jonathan Schafer <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message news:<ni********************************@4ax.com>. ..
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

Nov 13 '05 #8

P: n/a
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(TheCl ippedBmp) ;

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


"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:ni********************************@4ax.com...
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"
<an**********@hotmail.com> wrote:
I don't have a code yet. This is what I wanted to do. Create a small clippedimage from a bigger image and found there is no easy way and I need some
help.

Any suggestions please?

"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:ac********************************@4ax.com.. .
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"
<an**********@hotmail.com> wrote:

>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 >news:e9********************************@4ax.com.. .
>> 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\bi n\openssl-0.9.6d\doc\opens

sl
>_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"
>> <an**********@hotmail.com> wrote:
>>
>> >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
imageof
>the
>> >bigger Image.
>> >
>> >Any more suggestions please?
>> >
>> >Regards
>> >Anand Ganesh
>> >
>> >
>> >"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in

message
>> >news:q5********************************@4ax.com.. .
>> >> 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"
>> >> <an**********@hotmail.com> wrote:
>> >>
>> >> >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
>> >> >
>> >>
>> >
>>
>

Nov 13 '05 #9

P: n/a
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(TheCl ippedBmp) ;

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" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:cj********************************@4ax.com...
See embedded comments below:

Jonathan Schafer

On Mon, 14 Jul 2003 23:49:48 -0700, "Anand Ganesh"
<an**********@hotmail.com> wrote:
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 theimg ] [Is the clipping occurring here?]
Graphics g2 = pictureBox2.CreateGraphics();
[creating g2]
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height); [Drawing the bmpin 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(TheC lippedBmp) ;

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 inmy lifetime if you could say what I am missing.

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

Regards

Anand Ganesh


"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:ni********************************@4ax.com.. .
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"
<an**********@hotmail.com> wrote:

>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?
>
>"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message >news:ac********************************@4ax.com.. .
>> 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"
>> <an**********@hotmail.com> wrote:
>>
>> >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
>> >news:e9********************************@4ax.com.. .
>> >> 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\b in\openssl-0.9.6d\doc\open ss
>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"
>> >> <an**********@hotmail.com> wrote:
>> >>
>> >> >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
>> >> >news:q5********************************@4ax.com.. .
>> >> >> 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"
>> >> >> <an**********@hotmail.com> wrote:
>> >> >>
>> >> >> >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
>> >> >> >
>> >> >>
>> >> >
>> >>
>> >
>>
>

Nov 13 '05 #10

P: n/a
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(TheCl ippedBmp) ;

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" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:cj********************************@4ax.com...
See embedded comments below:

Jonathan Schafer

On Mon, 14 Jul 2003 23:49:48 -0700, "Anand Ganesh"
<an**********@hotmail.com> wrote:
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 theimg ] [Is the clipping occurring here?]
Graphics g2 = pictureBox2.CreateGraphics();
[creating g2]
g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height); [Drawing the bmpin 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(TheC lippedBmp) ;

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 inmy lifetime if you could say what I am missing.

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

Regards

Anand Ganesh


"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:ni********************************@4ax.com.. .
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"
<an**********@hotmail.com> wrote:

>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?
>
>"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message >news:ac********************************@4ax.com.. .
>> 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"
>> <an**********@hotmail.com> wrote:
>>
>> >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
>> >news:e9********************************@4ax.com.. .
>> >> 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\b in\openssl-0.9.6d\doc\open ss
>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"
>> >> <an**********@hotmail.com> wrote:
>> >>
>> >> >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
>> >> >news:q5********************************@4ax.com.. .
>> >> >> 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"
>> >> >> <an**********@hotmail.com> wrote:
>> >> >>
>> >> >> >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
>> >> >> >
>> >> >>
>> >> >
>> >>
>> >
>>
>

Nov 13 '05 #11

P: n/a
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"
<an**********@hotmail.com> wrote:
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.ToolBarButtonClickEventArg s 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(TheC lippedBmp) ;

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" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:cj********************************@4ax.com.. .
See embedded comments below:

Jonathan Schafer

On Mon, 14 Jul 2003 23:49:48 -0700, "Anand Ganesh"
<an**********@hotmail.com> wrote:
>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\bi n\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 Imgwidth >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 fromthe >img ] [Is the clipping occurring here?]
>Graphics g2 = pictureBox2.CreateGraphics();
>[creating g2]
>g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height); [Drawing thebmp >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 = newBitmap((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(TheC lippedBmp) ;
>
>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 forgetin >my lifetime if you could say what I am missing.
>
>
>
>Thanks for spending your precious time to teach Newbie like me.
>
>Regards
>
>Anand Ganesh
>
>
>
>
>
>
>"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
>news:ni********************************@4ax.com.. .
>> 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"
>> <an**********@hotmail.com> wrote:
>>
>> >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 needsome >> >help.
>> >
>> >Any suggestions please?
>> >
>> >"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote inmessage >> >news:ac********************************@4ax.com.. .
>> >> 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"
>> >> <an**********@hotmail.com> wrote:
>> >>
>> >> >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 ofdrawing >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
>> >> >news:e9********************************@4ax.com.. .
>> >> >> The following code works for me. It loads a .gif, draws the 30 x30 >> >> >> 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\opens >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"
>> >> >> <an**********@hotmail.com> wrote:
>> >> >>
>> >> >> >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 froman >> >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> wrotein >> >message
>> >> >> >news:q5********************************@4ax.com.. .
>> >> >> >> Create a graphics object from a bitmap and draw into it usingthe >> >> >> >> image from the other graphics object. You can specify thesource >> >and
>> >> >> >> dest rects.
>> >> >> >>
>> >> >> >> Jonathan Schafer
>> >> >> >>
>> >> >> >> On Fri, 11 Jul 2003 18:49:11 -0700, "Anand Ganesh"
>> >> >> >> <an**********@hotmail.com> wrote:
>> >> >> >>
>> >> >> >> >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
>> >> >> >> >
>> >> >> >>
>> >> >> >
>> >> >>
>> >> >
>> >>
>> >
>>
>


Nov 13 '05 #12

P: n/a
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" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:85********************************@4ax.com...
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"
<an**********@hotmail.com> wrote:
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 andwhen the user zooms in or zooms out or pan. Then applying this ImageRect onthe original image so that the right portion of the image is drawn for theuser.

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 imagefile.

private void toolBarIB_ButtonClick(object sender,
System.Windows.Forms.ToolBarButtonClickEventArg s 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(TheC lippedBmp) ;

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" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:cj********************************@4ax.com.. .
See embedded comments below:

Jonathan Schafer

On Mon, 14 Jul 2003 23:49:48 -0700, "Anand Ganesh"
<an**********@hotmail.com> wrote:

>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\bi n\openssl-0.9.6d\doc\opens

sl
>_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(TheC lippedBmp) ;
>
>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
>
>
>
>
>
>
>"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in
message >news:ni********************************@4ax.com.. .
>> 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"
>> <an**********@hotmail.com> wrote:
>>
>> >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?
>> >
>> >"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in

message
>> >news:ac********************************@4ax.com.. .
>> >> 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"
>> >> <an**********@hotmail.com> wrote:
>> >>
>> >> >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
>> >> >news:e9********************************@4ax.com.. .
>> >> >> The following code works for me. It loads a .gif, draws the 30 x30
>> >> >> 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 ns
>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"
>> >> >> <an**********@hotmail.com> wrote:
>> >> >>
>> >> >> >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
froman
>> >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> wrotein
>> >message
>> >> >> >news:q5********************************@4ax.com.. .
>> >> >> >> Create a graphics object from a bitmap and draw into it
usingthe
>> >> >> >> 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"
>> >> >> >> <an**********@hotmail.com> wrote:
>> >> >> >>
>> >> >> >> >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
>> >> >> >> >
>> >> >> >>
>> >> >> >
>> >> >>
>> >> >
>> >>
>> >
>>
>

Nov 13 '05 #13

P: n/a
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
On Tue, 15 Jul 2003 15:07:32 -0700, "Anand Ganesh"
<an**********@hotmail.com> wrote:
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" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:85********************************@4ax.com.. .
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"
<an**********@hotmail.com> wrote:
>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 clipboardand >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 fewbuttons. >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 clickscopy, >I want that zoomed portion of the image to be transfered to theclipboard. >
>Here is the code after the user clicks the button.
>
>The ImageRect is a RectangleF object and I am manipulating its values asand >when the user zooms in or zooms out or pan. Then applying this ImageRecton >the original image so that the right portion of the image is drawn forthe >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 .tifimage >file.
>
>private void toolBarIB_ButtonClick(object sender,
>System.Windows.Forms.ToolBarButtonClickEventArg s 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 = newBitmap((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(TheC lippedBmp) ;
>
>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" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
>news:cj********************************@4ax.com.. .
>> See embedded comments below:
>>
>> Jonathan Schafer
>>
>> On Mon, 14 Jul 2003 23:49:48 -0700, "Anand Ganesh"
>> <an**********@hotmail.com> wrote:
>>
>> >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); [ Createsan >> >empty bmp of size 30 x 30 ]
>> >Image
>>

img=System.Drawing.Image.FromFile(@"C:\cygwin\b in\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); [Drawingthe >> >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 copyto >> >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(TheC lippedBmp) ;
>> >
>> >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 notforget >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
>> >
>> >
>> >
>> >
>> >
>> >
>> >"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote inmessage >> >news:ni********************************@4ax.com.. .
>> >> 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"
>> >> <an**********@hotmail.com> wrote:
>> >>
>> >> >I don't have a code yet. This is what I wanted to do. Create asmall >> >clipped
>> >> >image from a bigger image and found there is no easy way and I need
>some
>> >> >help.
>> >> >
>> >> >Any suggestions please?
>> >> >
>> >> >"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in
>message
>> >> >news:ac********************************@4ax.com.. .
>> >> >> Shouldn't matter. A gif file is a 256 color palette indexedimage. >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"
>> >> >> <an**********@hotmail.com> wrote:
>> >> >>
>> >> >> >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 afile. >> >> >> >
>> >> >> >Regards
>> >> >> >Anand Ganesh
>> >> >> >
>> >> >> >"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrotein >> >message
>> >> >> >news:e9********************************@4ax.com.. .
>> >> >> >> The following code works for me. It loads a .gif, draws the30 x >30
>> >> >> >> section of the gif into an offscreen bitmap, and then drawsthe >> >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"
>> >> >> >> <an**********@hotmail.com> wrote:
>> >> >> >>
>> >> >> >> >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 createdfrom >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 aclipped >> >image
>> >> >of
>> >> >> >the
>> >> >> >> >bigger Image.
>> >> >> >> >
>> >> >> >> >Any more suggestions please?
>> >> >> >> >
>> >> >> >> >Regards
>> >> >> >> >Anand Ganesh
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com>wrote >in
>> >> >message
>> >> >> >> >news:q5********************************@4ax.com.. .
>> >> >> >> >> Create a graphics object from a bitmap and draw into itusing >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"
>> >> >> >> >> <an**********@hotmail.com> wrote:
>> >> >> >> >>
>> >> >> >> >> >HI All,
>> >> >> >> >> >
>> >> >> >> >> >I have an Image. I want to clip a portion of it and copyto >> >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
>> >> >> >> >> >
>> >> >> >> >>
>> >> >> >> >
>> >> >> >>
>> >> >> >
>> >> >>
>> >> >
>> >>
>> >
>>
>


Nov 13 '05 #14

P: n/a
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" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:e3********************************@4ax.com...
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
On Tue, 15 Jul 2003 15:07:32 -0700, "Anand Ganesh"
<an**********@hotmail.com> wrote:
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 takenplace.]

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" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:85********************************@4ax.com.. .
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"
<an**********@hotmail.com> wrote:

>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 asand
>when the user zooms in or zooms out or pan. Then applying this
ImageRecton
>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.ToolBarButtonClickEventArg s 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(TheC lippedBmp) ;
>
>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" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in
message >news:cj********************************@4ax.com.. .
>> See embedded comments below:
>>
>> Jonathan Schafer
>>
>> On Mon, 14 Jul 2003 23:49:48 -0700, "Anand Ganesh"
>> <an**********@hotmail.com> wrote:
>>
>> >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); [ Createsan
>> >empty bmp of size 30 x 30 ]
>> >Image
>>
img=System.Drawing.Image.FromFile(@"C:\cygwin\b in\openssl-0.9.6d\doc\open
ss
>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); [Drawingthe
>> >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 copyto
>> >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(TheC lippedBmp) ;
>> >
>> >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
>> >
>> >
>> >
>> >
>> >
>> >
>> >"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in

message
>> >news:ni********************************@4ax.com.. .
>> >> 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"
>> >> <an**********@hotmail.com> wrote:
>> >>
>> >> >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?
>> >> >
>> >> >"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in >message
>> >> >news:ac********************************@4ax.com.. .
>> >> >> 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"
>> >> >> <an**********@hotmail.com> wrote:
>> >> >>
>> >> >> >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> wrotein
>> >message
>> >> >> >news:e9********************************@4ax.com.. .
>> >> >> >> The following code works for me. It loads a .gif, draws
the30 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

en
>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"
>> >> >> >> <an**********@hotmail.com> wrote:
>> >> >> >>
>> >> >> >> >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 createdfrom
>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
>> >> >> >> >news:q5********************************@4ax.com.. .
>> >> >> >> >> 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"
>> >> >> >> >> <an**********@hotmail.com> wrote:
>> >> >> >> >>
>> >> >> >> >> >HI All,
>> >> >> >> >> >
>> >> >> >> >> >I have an Image. I want to clip a portion of it and

copyto
>> >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
>> >> >> >> >> >
>> >> >> >> >>
>> >> >> >> >
>> >> >> >>
>> >> >> >
>> >> >>
>> >> >
>> >>
>> >
>>
>

Nov 13 '05 #15

P: n/a
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
On Tue, 15 Jul 2003 18:54:31 -0700, "Anand Ganesh"
<an**********@hotmail.com> wrote:
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" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:e3********************************@4ax.com.. .
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
On Tue, 15 Jul 2003 15:07:32 -0700, "Anand Ganesh"
<an**********@hotmail.com> wrote:
>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 notclipped. >The reason is as follows
>
>System.Drawing.Bitmap TheClippedBmp = newBitmap((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 hastaken >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" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
>news:85********************************@4ax.com.. .
>> 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"
>> <an**********@hotmail.com> wrote:
>>
>> >It is not throwing Exception but I am expecting it will copy theclipped >> >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 toclipboard >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 valuesas >and
>> >when the user zooms in or zooms out or pan. Then applying thisImageRect >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.ToolBarButtonClickEventArg s 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(TheC lippedBmp) ;
>> >
>> >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" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote inmessage >> >news:cj********************************@4ax.com.. .
>> >> See embedded comments below:
>> >>
>> >> Jonathan Schafer
>> >>
>> >> On Mon, 14 Jul 2003 23:49:48 -0700, "Anand Ganesh"
>> >> <an**********@hotmail.com> wrote:
>> >>
>> >> >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 fullImg >> >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 portionfrom >> >the
>> >> >img ] [Is the clipping occurring here?]
>> >> >Graphics g2 = pictureBox2.CreateGraphics();
>> >> >[creating g2]
>> >> >g2.DrawImageUnscaled(bmp, 0, 0, bmp.Width, bmp.Height); [Drawingthe >> >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 andcopy >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(TheC lippedBmp) ;
>> >> >
>> >> >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 cropthe >> >> 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
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in
>message
>> >> >news:ni********************************@4ax.com.. .
>> >> >> I've given you the sample code that does just that. It loads agif >> >> >> file, copies a 30 x 30 portion ( rect(0, 0, 29, 29) of theoriginal >> >> >> into the new bitmap, and draws both to a picturebox to ensurethat I >> >> >> am cropping the image correctly.
>> >> >>
>> >> >> What more do you want?
>> >> >>
>> >> >> Jonathan Schafer
>> >> >>
>> >> >>
>> >> >> On Mon, 14 Jul 2003 10:42:11 -0700, "Anand Ganesh"
>> >> >> <an**********@hotmail.com> wrote:
>> >> >>
>> >> >> >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 Ineed >> >some
>> >> >> >help.
>> >> >> >
>> >> >> >Any suggestions please?
>> >> >> >
>> >> >> >"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrotein >> >message
>> >> >> >news:ac********************************@4ax.com.. .
>> >> >> >> 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 youdoing. >> >> >> >>
>> >> >> >> Jonathan Schafer
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> On Mon, 14 Jul 2003 09:11:54 -0700, "Anand Ganesh"
>> >> >> >> <an**********@hotmail.com> wrote:
>> >> >> >>
>> >> >> >> >Hi,
>> >> >> >> >
>> >> >> >> >See you have a .gif image. I have .tif image. May be that isthe >> >> >problem.
>> >> >> >> >Also I am not sure how to get another image itself; insteadof >> >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
>> >> >> >> >news:e9********************************@4ax.com.. .
>> >> >> >> >> The following code works for me. It loads a .gif, drawsthe >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:\cygwi n\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"
>> >> >> >> >> <an**********@hotmail.com> wrote:
>> >> >> >> >>
>> >> >> >> >> >I tried this but I got an error
>> >> >> >> >> >
>> >> >> >> >> >
>> >> >> >> >> >An unhandled exception of type 'System.Exception' occurredin >> >> >> >> >> >system.drawing.dll
>> >> >> >> >> >
>> >> >> >> >> >Additional information: A Graphics object cannot becreated >from
>> >an
>> >> >> >image
>> >> >> >> >> >that has an indexed pixel format.
>> >> >> >> >> >
>> >> >> >> >> >
>> >> >> >> >> >But the problem is after clipping I need another Imageobject >> >> >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
>> >> >> >> >> >news:q5********************************@4ax.com.. .
>> >> >> >> >> >> Create a graphics object from a bitmap and draw into it
>using
>> >the
>> >> >> >> >> >> image from the other graphics object. You can specifythe >> >source
>> >> >> >and
>> >> >> >> >> >> dest rects.
>> >> >> >> >> >>
>> >> >> >> >> >> Jonathan Schafer
>> >> >> >> >> >>
>> >> >> >> >> >> On Fri, 11 Jul 2003 18:49:11 -0700, "Anand Ganesh"
>> >> >> >> >> >> <an**********@hotmail.com> wrote:
>> >> >> >> >> >>
>> >> >> >> >> >> >HI All,
>> >> >> >> >> >> >
>> >> >> >> >> >> >I have an Image. I want to clip a portion of it andcopy >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
>> >> >> >> >> >> >
>> >> >> >> >> >>
>> >> >> >> >> >
>> >> >> >> >>
>> >> >> >> >
>> >> >> >>
>> >> >> >
>> >> >>
>> >> >
>> >>
>> >
>>
>


Nov 13 '05 #16

This discussion thread is closed

Replies have been disabled for this discussion.