Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Sunday, July 22, 2007 10:09:50 PM(UTC)

manju  
manju

Groups: Registered
Posts: 49


Hi,

Is it possible to crop an image in elliptical shape using leadtool 15 in C# .net,if so then how??

Thanks
Manju
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Monday, July 23, 2007 11:50:58 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

Was thanked: 1 time(s) in 1 post(s)

Hello,

In general, there are no elliptical images. Images always have rectangular shape. There is no direct way to crop the image in elliptical shape.

However, you can get an elliptical shape for the image by adding an elliptical region on the image, and then fill the region outside the ellipse with black or white color.


Also, you may try to workaround this by creating an elliptical region on the image, convert this region to floater image and then copy or save the floater image.
You can do this by using the following code:
+-------------+
RasterCodecs.Startup()
Dim codecs As RasterCodecs = New RasterCodecs()

Dim image As RasterImage = RasterImageViewer1.Image.Clone()

Dim xform As RasterRegionXForm = New RasterRegionXForm()
xform.ViewPerspective = RasterViewPerspective.TopLeft
xform.XOffset = 0
xform.YOffset = 0
xform.XScalarDenominator = 1
xform.XScalarNumerator = 1
xform.YScalarDenominator = 1
xform.YScalarNumerator = 1

Dim rc As Rectangle = New Rectangle(image.ImageWidth \ 4, image.ImageHeight \ 4, image.ImageWidth \ 3, image.ImageHeight \ 3)

image.AddEllipseToRegion(xform, rc, RasterRegionCombineMode.Set)

RasterImageViewer1.EnableTimer = True
RasterImageViewer1.RegionToFloater()
RasterImageViewer1.FloaterVisible = True
RasterImageViewer1.AnimateFloater = True

RasterImageViewer1.Image.MakeRegionEmpty()
image = RasterImageViewer1.FloaterImage.Clone()
RasterImageViewer1.FloaterImage = Nothing
RasterImageViewer1.Image = image.Clone()

RasterCodecs.Shutdown()
+-------------+

Please let me know if this helps.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Tuesday, July 24, 2007 3:27:59 AM(UTC)

manju  
manju

Groups: Registered
Posts: 49


If i use above code i will get exception at
image = RasterImageViewer1.FloaterImage.Clone()

that object reference not set to an instance,value of RasterImageViewer1.FloaterImage remaince null
and if i set RasterImageViewer1.FloaterImage=image
before
image = RasterImageViewer1.FloaterImage.Clone()
this statement it works but only draws ellipse on image.
Tell me how to extract any region like ellipse or free hand region from an image in c# .net and leadtools 15.Please Reply ASAP

Thanks
Manju
 
#4 Posted : Tuesday, July 24, 2007 11:54:59 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

Was thanked: 1 time(s) in 1 post(s)

Hello,

Try to use the following code:
+---------------------------+
RasterCodecs.Startup()
Dim codecs As RasterCodecs = New RasterCodecs()
Dim image As RasterImage = RasterImageViewer1.Image

Dim rc As Rectangle = New Rectangle(image.ImageWidth \ 4, image.ImageHeight \ 4, image.ImageWidth \ 3, image.ImageHeight \ 3)

image.AddEllipseToRegion(Nothing, rc, RasterRegionCombineMode.Set)

RasterImageViewer1.EnableTimer = True
RasterImageViewer1.RegionToFloater()
RasterImageViewer1.FloaterVisible = True
RasterImageViewer1.AnimateFloater = True

image = RasterImageViewer1.FloaterImage.Clone()
RasterImageViewer1.FloaterImage = Nothing

RasterImageViewer1.Image = image.Clone()

rc = RasterImageViewer1.Image.GetRegionBounds(Nothing)

RasterImageViewer1.Image.MakeRegionEmpty()
RasterImageViewer1.Image.AddEllipseToRegion(Nothing, rc, RasterRegionCombineMode.SetNot)

Dim command As FillCommand = New FillCommand()
command.Color = New RasterColor(0, 0, 255)
command.Run(RasterImageViewer1.Image)

RasterCodecs.Shutdown()
+---------------------------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#5 Posted : Wednesday, July 25, 2007 2:47:09 AM(UTC)

manju  
manju

Groups: Registered
Posts: 49


Hi,

Please check the attached form.cs file and screen shot,as show in image i want that only selected region will get displayed,so will you please tell me what changes i should do in code to get that result.
Please reply soon.

Thanks
Manju
File Attachment(s):
Cropping.zip (39kb) downloaded 21 time(s).
 
#6 Posted : Sunday, July 29, 2007 9:46:30 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,328

Was thanked: 1 time(s) in 1 post(s)

Hello,

I checked your code with the screenshot image.
To display the selected region only on the RasterImageViewer, try to sue the following code:
+-----------------------+
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

RasterImageViewer1.InteractiveMode = RasterViewerInteractiveMode.Region
RasterImageViewer1.InteractiveRegionType = RasterViewerInteractiveRegionType.Freehand

End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click

RasterImageViewer1.RegionToFloater()
RasterImageViewer1.FloaterVisible = True

RasterImageViewer1.InteractiveMode = RasterViewerInteractiveMode.Floater
RasterImageViewer1.Image.MakeRegionEmpty()

RasterImageViewer1.Image = Nothing
RasterImageViewer1.Image = RasterImageViewer1.FloaterImage

Dim rc As Rectangle = RasterImageViewer1.Image.GetRegionBounds(Nothing)
RasterImageViewer1.Image.MakeRegionEmpty()
RasterImageViewer1.Image.AddEllipseToRegion(Nothing, rc, RasterRegionCombineMode.SetNot)

Dim command As FillCommand = New FillCommand()
command.Color = New RasterColor(RasterImageViewer1.BackColor)
command.Run(RasterImageViewer1.Image)

RasterImageViewer1.FloaterImage = Nothing
RasterImageViewer1.Image.MakeRegionEmpty()

End Sub
+-----------------------+

Please let me know if this helps.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.168 seconds.