This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Notification

Icon
Error

Options
Go to last post Go to first unread
sajjarapu  
#1 Posted : Friday, February 27, 2009 12:13:18 AM(UTC)
sajjarapu

Rank: Newbie

Groups: Guest
Joined: 6/3/2008(UTC)
Posts: 7

Hi,

Clicking on the "Apply Crop" button crops the image and then refreshes the imagePanel with the new crop image. Would it be possible to change this behavior? Ideally we would like to save the cropped image to the directory when the user clicks on "Apply Crop" and redirect them to a new page and show them the cropped image. Currently users have to click on Apply Crop and then Click on Save Changes. Would it be possible for us to change this? Please advise
Tamila  
#2 Posted : Sunday, March 1, 2009 9:25:32 PM(UTC)
Tamila

Rank: Advanced Member

Groups: Guest
Joined: 3/9/2008(UTC)
Posts: 554

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

You just need to implement the following correction:

In Default.aspx you should correct Form1:
Code:
<form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"/>
        <div>
            <!-- Add the custom control -->
            <aur:MyControl runat="server" ID="myControl1" />
        </div>
    </form>



In PhotoEditor\Scripts\Effects\CropEffect.js correct this function:
Code:
_onApplyButtonClick: function(evt) {
		/// <private />
		var controller = $find(this._controllerId);
		var rr = $find(controller.get_rectangleRubberbandId());
		var bv = $find(controller.get_bitmapViewerId());
		if ((this._selectedSize != -1) && (rr) && (bv)) {
			// Get rectangle.
			var rect = rr.get_rectangle();

			// Set new crop rectangle.
			this._cropRect = this._transformedToOriginal(new Array(rect.x, rect.y, rect.width, rect.height));

			this._oldRect = new Array(rect.x, rect.y, rect.width, rect.height);
			//this._update();
			PageMethods.ApplyCropEffect(Sys.Serialization.JavaScriptSerializer.serialize({FileName: bv._bitmap$fileName, 
                    X: this._cropRect[0], Y: this._cropRect[1],
                    Width: this._cropRect[2], Height: this._cropRect[3] }), 
                function(result, userContext, methodName) { document.location = result; });


		}
		return false;
	},


In PhotoEditorSample\Default.aspx.cs you shoul add the following class and references:
Code:

using Aurigma.GraphicsMill.AjaxControls;
using Aurigma.GraphicsMill;
using System.Web.Script.Serialization;

PhotoEditorDefault
  private struct CropParams
    {
        public string FileName;
        public float X;
        public float Y;
        public float Width;
        public float Height;
    }

    [System.Web.Services.WebMethod]
    public static string ApplyCropEffect(string context)
    {
        JavaScriptSerializer jss = new JavaScriptSerializer();
        CropParams crop = jss.Deserialize<CropParams>(context);
        string _bitmapFileName = crop.FileName;
        Bitmap _bitmap = new Bitmap();
        FileCache fc = FileCache.GetInstance();
        using (System.IO.FileStream stream =
                               new System.IO.FileStream(fc.GetAbsolutePrivateCachePath(_bitmapFileName), System.IO.FileMode.Open, System.IO.FileAccess.Read))
        {
            _bitmap.Deserialize(stream);
        }
        _bitmap.Transforms.Crop(crop.X, crop.Y, crop.Width, crop.Height);
        string fileName = fc.GetPublicTempFileName(".jpg");
        _bitmap.Save(fc.GetAbsolutePublicCachePath(fileName));
        return fc.GetRelativePublicCachePath(fileName);
    }

Edited by user Monday, March 9, 2009 8:35:34 PM(UTC)  | Reason: Not specified

Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!
sajjarapu  
#3 Posted : Wednesday, March 4, 2009 4:36:26 AM(UTC)
sajjarapu

Rank: Newbie

Groups: Guest
Joined: 6/3/2008(UTC)
Posts: 7

Hi Tamila,

I made these changes. However I get a Javascript error when I click on the "Apply Crop Button".

'PageMethods' is undefined.

Please advise

Thanks
Sri

Tamila  
#4 Posted : Monday, March 9, 2009 8:37:12 PM(UTC)
Tamila

Rank: Advanced Member

Groups: Guest
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
I have prepared sample project of Photo Editor for you. Try to use it.
Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!
sajjarapu  
#5 Posted : Monday, March 9, 2009 8:45:45 PM(UTC)
sajjarapu

Rank: Newbie

Groups: Guest
Joined: 6/3/2008(UTC)
Posts: 7

Hi Tamila,

How can I access the sample project? Are you referring to your original post? Please advise

Thanks
Sri
Tamila  
#6 Posted : Monday, March 9, 2009 9:19:33 PM(UTC)
Tamila

Rank: Advanced Member

Groups: Guest
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
You can download it here:
PhotoEditorSolution
Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!
Users browsing this topic
Guest (3)
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.