Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
cpav  
#1 Posted : Sunday, March 16, 2008 8:33:05 PM(UTC)
cpav

Rank: Advanced Member

Groups: Member
Joined: 12/17/2007(UTC)
Posts: 49

Hi,

we use a code similar to Main sample about operations with filters. This is the code we use for Buttonize effect:

Dim but As New Buttonize
but.BorderWidth = BorderWidth 'for example 10
but.Direction = Direction.Up
but.FadeType = FadeType.Linear
ApplyTransform(but)

After this, the image(the whole area of image) gets the effect. When we first select an area of the image with select tool, and after we apply the effect, the effect applies again to the whole image and not only on the selected area.

What do we have to change so the filter applies only to the selected area ?

cpav
File Attachment(s):
applyFilterToAreaSample.zip (99kb) downloaded 3 time(s).
Alex Kon  
#2 Posted : Wednesday, March 19, 2008 1:51:04 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups:
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hi,

You should use MaskedTransforms functionality to apply effect on the part of the image.

Edited by user Tuesday, October 28, 2008 8:30:24 PM(UTC)  | Reason: Not specified

Alex Kon  
#3 Posted : Wednesday, March 19, 2008 1:59:40 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups:
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Oh, another way - you can copy part of the original image (e.g. with Crop transform), apply your transform to that piece and then draw it back to the original image.

The way to choose depends on the specific of your task. Using masked transforms is more common way while the crop-apply-and-copy-back way may be faster in some cases.

I recommend you to use the first and try the former only in case of any issues.

Edited by user Tuesday, October 28, 2008 7:11:49 AM(UTC)  | Reason: Not specified

cpav  
#4 Posted : Thursday, March 20, 2008 12:05:05 AM(UTC)
cpav

Rank: Advanced Member

Groups: Member
Joined: 12/17/2007(UTC)
Posts: 49

Hi Alex,

well what i need is the first way, MaskedTransforms. But i need little help on how to do this. On my INITIAL post, i added an attached zip file. It's a tiny,simple project that does transform for 1 whole image. Please have a look at it and tell me if you can, what we need to add for the last button!

Thanks for helping
Alex Kon  
#5 Posted : Monday, March 24, 2008 6:15:58 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups:
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello,

I have some problem here with your sample - Texturize transform is not descendant of the MaskedBitmapTransform class, so it is impossible to use it with custom masks.

However, I decided that it is a good chance to demonstrate another way - "crop-transform-draw". Here is method which applies texturize transform only to the selected part of the image:

Code:

Private Sub Button3_Click(ByVal sender As System.Object, 
	ByVal e As System.EventArgs) Handles Button3.Click

	If (bitmapViewerMainView.Bitmap.IsEmpty Or 
		rectangleRubberbandSelect.Rectangle.Width < 1 Or 
		rectangleRubberbandSelect.Rectangle.Height < 1) Then
		Return
	End If

	' 1) We need to extract specified part of the bitmap 
	Dim roi As New Aurigma.GraphicsMill.Bitmap()
	Dim cropTransform As New Aurigma.GraphicsMill.Transforms.Crop()
	cropTransform.Rectangle = rectangleRubberbandSelect.Rectangle
	cropTransform.ApplyTransform(bitmapViewerMainView.Bitmap, roi)

	' 2) Now we should apply texturize transform to this region
	roi.Transforms.Texturize(3, 3)

	' 3) And put this patch back to the original image
	roi.Draw(bitmapViewerMainView.Bitmap, 
		rectangleRubberbandSelect.Rectangle,
		Aurigma.GraphicsMill.Transforms.CombineMode.Copy, 
		1.0, 
		Aurigma.GraphicsMill.Transforms.InterpolationMode.HighSpeed)

End Sub


As for code sample with MaskedTransforms - you can use one from the Overlaying Images article, "Masked Transforms" section. If you need any other specific sample - feel free to ask!

Edited by user Wednesday, October 29, 2008 1:58:40 PM(UTC)  | Reason: Not specified

cpav  
#6 Posted : Tuesday, March 25, 2008 6:46:14 AM(UTC)
cpav

Rank: Advanced Member

Groups: Member
Joined: 12/17/2007(UTC)
Posts: 49

This is working, but the Undo operation is not working using "crop-transform-draw" method.
Can we have some code that does any kind of transformation on a selected area, and which can Undo using code

Code:
bitmapViewerMainView.Bitmap.Undo()
?


Alex Kon  
#7 Posted : Tuesday, March 25, 2008 7:20:09 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups:
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hi,

Are you sure that "UndoRedoEnabled" property of the bitmap is set to true? I attached your sample with my modifications to this post.

Please, could you check it and let me know if you have any problems with Undo/Redo in your enviroment.

File Attachment(s):
filterSample.zip (17kb) downloaded 3 time(s).
cpav  
#8 Posted : Wednesday, March 26, 2008 8:24:07 PM(UTC)
cpav

Rank: Advanced Member

Groups: Member
Joined: 12/17/2007(UTC)
Posts: 49

Well, it works fine in true application, so everything is ok Alex.

As you told us, we use this code

Code:
 roi.Transforms.Texturize(3, 3)


Everything is ok, but when we try to do the same for Solarize filter, it does not exist.

roi.Transforms. has Cylindrize, Emboss, Glow and all the filters you have in MainDemo sample except Solarize!.

Is it going to be included maybe in next revision or version of GM or this is different story and will not be done?
I just want to know if i will put a follow up on this waiting to be included, or just forget it and continue without having it on my mind.

Thanks again Alex
Alex Kon  
#9 Posted : Wednesday, March 26, 2008 9:13:32 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups:
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hi,

Solarize transform was classified in another way. Along with Leves, HistogramEqualize, Brightness/Contrast and similar transforms it was placed into "ColorAdjustment" helper, so you should write such line:

Code:
roi.ColorAdjustment.Solarize()


Yeah, I know that it is a little unexpected in the first time ;)
Users browsing this topic
Forum Jump  
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.