DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Mon, 13 Aug 2007 01:20:01 -0700,    posted on: microsoft.public.dotnet.framework.drawing        back       

Thread Index
  1    Ruby Nadler
          2    Michael C
                 3    Ruby Nadler
                 4    Michael C
                        5    Ruby Nadler
                 6    Ruby Nadler
                        7    Jeff Johnson
                 8    Michael C
                 9    Ruby Nadler


copy and paste region   
Hi everyone,
how can i draw a region (polygon or Ellipse) on a bitmap, copy the region i 
markes and paste it on a othe image or picture box?
thanks,
Ruby
Date:Mon, 13 Aug 2007 01:20:01 -0700   Author:  

Re: copy and paste region   
"Ruby Nadler"  wrote in message 
news:FFD5F534-0368-49C8-AF84-88872D1BACB8@microsoft.com...

> Hi everyone,
> how can i draw a region (polygon or Ellipse) on a bitmap, copy the region 
> i
> markes and paste it on a othe image or picture box?


Yes. Create a region and use it as the clipping region when you draw one 
bitmap onto the other.


> thanks,
> Ruby 
Date:Tue, 14 Aug 2007 13:53:18 +1000   Author:  

Re: copy and paste region   
Can you show me in a small code, I am new to it.
Thanks

"Michael C" wrote:


> "Ruby Nadler"  wrote in message 
> news:FFD5F534-0368-49C8-AF84-88872D1BACB8@microsoft.com...
> > Hi everyone,
> > how can i draw a region (polygon or Ellipse) on a bitmap, copy the region 
> > i
> > markes and paste it on a othe image or picture box?
> 
> Yes. Create a region and use it as the clipping region when you draw one 
> bitmap onto the other.
> 
> > thanks,
> > Ruby 
> 
> 
> 
Date:Mon, 13 Aug 2007 21:00:02 -0700   Author:  

Re: copy and paste region   
"Ruby Nadler"  wrote in message 
news:0BB5B967-E83A-4E3D-AFEE-FA6C93F48A9D@microsoft.com...

> Can you show me in a small code, I am new to it.
> Thanks


Something like this:

   GraphicsPath path = new GraphicsPath(MyPoints);//put your array of points 
in here
   Region region = new Region(path);
   Bitmap bitmap1 = Whatever;//source bitmap
   Bitmap bitmap2 = Whatever;//destination bitmap
   Graphics g = Graphics.FromImage(bitmap2);
   g.SetClip(region);
   g.DrawImage(bitmap1);
   g.Dispose();
   region.Dispose();
   path.Dispose();



>>
>> 
Date:Tue, 14 Aug 2007 14:21:19 +1000   Author:  

Re: copy and paste region   
thanks alot, you realy helped

"Michael C" wrote:


> "Ruby Nadler"  wrote in message 
> news:0BB5B967-E83A-4E3D-AFEE-FA6C93F48A9D@microsoft.com...
> > Can you show me in a small code, I am new to it.
> > Thanks
> 
> Something like this:
> 
>    GraphicsPath path = new GraphicsPath(MyPoints);//put your array of points 
> in here
>    Region region = new Region(path);
>    Bitmap bitmap1 = Whatever;//source bitmap
>    Bitmap bitmap2 = Whatever;//destination bitmap
>    Graphics g = Graphics.FromImage(bitmap2);
>    g.SetClip(region);
>    g.DrawImage(bitmap1);
>    g.Dispose();
>    region.Dispose();
>    path.Dispose();
> 
> 
> >>
> >> 
> 
> 
> 
Date:Mon, 13 Aug 2007 22:58:03 -0700   Author:  

Re: copy and paste region   
Hi Michael,
i am using vb net not c# so i had to change the code. also what i need to do 
is copy a region from picture box to second picture box.
for Ellipse i changed the code to:

Dim recSource As New Rectangle(rectImage.Left, rectImage.Top, 
rectImage.Width, rectImage.Height) ' the ellips Rectangle

Dim bmpImage As New Bitmap(picImage.Width, picImage.Height) ' picImage 
source picturebox
Dim gImage As Graphics = Graphics.FromImage(bmpImage)

Dim gp As New System.Drawing.Drawing2D.GraphicsPath
Dim rgn As Region

gp.AddEllipse(0, 0, rectImage.Width, rectImage.Height)
rgn = New Region(gp)
gImage.SetClip(gp)
gImage.DrawImage(picImage.Image, 0, 0, recSource, GraphicsUnit.Pixel)

PictureBox1.Size = recSource.Size ' target picturebox
PictureBox1.Image = bmpImage

gImage.Dispose()
gp.Dispose()
rgn.Dispose()

in vb net DrawImage can not has only 1 parameter so i gave it the ellips 
Rectangle.

this works fine. when i try polygon it does not work (instesd of 
gp.AddEllipse i use gp.AddPolygon with array of points i collect from the 
mouse).

any idea?
thanks
"Michael C" wrote:


> "Ruby Nadler"  wrote in message 
> news:0BB5B967-E83A-4E3D-AFEE-FA6C93F48A9D@microsoft.com...
> > Can you show me in a small code, I am new to it.
> > Thanks
> 
> Something like this:
> 
>    GraphicsPath path = new GraphicsPath(MyPoints);//put your array of points 
> in here
>    Region region = new Region(path);
>    Bitmap bitmap1 = Whatever;//source bitmap
>    Bitmap bitmap2 = Whatever;//destination bitmap
>    Graphics g = Graphics.FromImage(bitmap2);
>    g.SetClip(region);
>    g.DrawImage(bitmap1);
>    g.Dispose();
>    region.Dispose();
>    path.Dispose();
> 
> 
> >>
> >> 
> 
> 
> 
Date:Tue, 14 Aug 2007 02:06:02 -0700   Author:  

Re: copy and paste region   
"Ruby Nadler"  wrote in message 
news:8A1DDCCC-F049-435A-9F01-B4278D004BB1@microsoft.com...

> in vb net DrawImage can not has only 1 parameter so i gave it the ellips
> Rectangle.


Same in C#, the code I posted originally was air code. For the rect you can 
just use the full rect of the image if you like. You might be able to 
optimise this by finding the smallest possible rect that bounds your path 
but it's not critical to do this.

Michael
Date:Wed, 15 Aug 2007 10:34:09 +1000   Author:  

Re: copy and paste region   
THANKS, I'LL TRY

"Michael C" wrote:


> "Ruby Nadler"  wrote in message 
> news:8A1DDCCC-F049-435A-9F01-B4278D004BB1@microsoft.com...
> > in vb net DrawImage can not has only 1 parameter so i gave it the ellips
> > Rectangle.
> 
> Same in C#, the code I posted originally was air code. For the rect you can 
> just use the full rect of the image if you like. You might be able to 
> optimise this by finding the smallest possible rect that bounds your path 
> but it's not critical to do this.
> 
> Michael 
> 
> 
> 
Date:Tue, 14 Aug 2007 20:20:01 -0700   Author:  

Re: copy and paste region   
"Ruby Nadler"  wrote in message 
news:8A1DDCCC-F049-435A-9F01-B4278D004BB1@microsoft.com...


> in vb net DrawImage can not has only 1 parameter so i gave it the ellips
> Rectangle.


For reference, it has nothing to do with the language. When you're dealing 
with classes and the methods they expose, their parameter lists are the same 
for all .NET languages. The only differences you might see would be between 
built-in statements that just happen to have the same names in different 
languages, and I can't even come up with an example off the top of my head.
Date:Fri, 17 Aug 2007 11:29:41 -0400   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us