This is a migrated thread and some comments may be shown as answers.

Upload to Server

6 Answers 92 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Aziz
Top achievements
Rank 1
Aziz asked on 19 Mar 2012, 04:49 PM
I am looking to see if this image editor has the same function as the asp.net ajax editor. that being that you can edit an image then save it to the server.

I have looked into a bit of this and can find no easy way to do it.

My thought was that I could override the save command (which i did) and then pass the image.bitmap as a property into a instance of the RadUploader and have that deal with the file delivery however this appears much harder than I expected.

Is there any sample code on how to save the result of an ImageEditorUI to server?

or how to convert the result into a RadUploadItem which i could then add to the items collection of a RadUploader and send?

6 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 19 Mar 2012, 05:12 PM
Hi Jacob,

You can obtain a reference to the Image previewed in RadImageEditor using the Image property. Then, you can use a format provider such as PngFormatProvider in order to encode the image to a stream or byte array.
After that, you can either use a WCF service or RadUpload in order to save the image on the server.

Please find attached a demo of RadImageEditor and RadUpload. You can refer to this article for information about the server configurations for RadUpload.

Kind regards,
Iva Toteva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Aziz
Top achievements
Rank 1
answered on 19 Mar 2012, 06:17 PM
When i attempt to run your solution using a jpg file from my computer i get IndexOutOfRangeException on line 36 of MySaveCommand.cs
0
Aziz
Top achievements
Rank 1
answered on 19 Mar 2012, 06:37 PM
after playing around with this more it appears to have something to do with file size. if i take this app and run it with my sample picture (attached) and invert the colors and save it will crash, if I re-run the app and select crop, then press enter twice (crop it twice) then save it works.

this is strange as i need it to be able to accept any sized image, so why does it crash if the picture is over a set size? i assume this is related to PngFormatProvider?
0
Viktor Tsvetkov
Telerik team
answered on 22 Mar 2012, 09:58 AM
Hello Jacob,

Actually the problem is in our RadZipLibrary which is used with the PngFormatProvider. The bug is known and is logged here so you can track and vote for it.

Kind regards,
Viktor Tsvetkov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Aziz
Top achievements
Rank 1
answered on 22 Mar 2012, 03:28 PM
thats not so good.

so is there some type of work around? can i export my image as jpg, bmp, something? if not how can i convert a radbitmap to a Image so that i can then use an external library to export this file?
0
Iva Toteva
Telerik team
answered on 22 Mar 2012, 04:03 PM
Hello Jacob,

The problem is with PngFormatProvider only, as it is the only one using the zip.

You can use BmpFormatProvider to export the image to bmp using analogical code to the one in the sample project. You just have to replace PngFormatProvider with BmpFormatProvider and change the extension of the image file. I tested how bmp export with the image you have attached and the image was successfully saved.

When it comes to JPEG, our JpegFormatProvider supports only import, but you can implement the export yourself, as described in this blogpost. There is also an attached sample project illustrating the implementation of JPEG format provider that allows export using FJ Core. The only thing that you would need to do to get it working with 2012 Q1 is to add the following property to the CustomJpegFormatProvider class:

public string FilesDescription
{
    get
    {
        return SupportedExtensions.First().Trim('.').ToUpper() + " Files";
    }
}

I hope this helps.

All the best,
Iva Toteva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
ImageEditor
Asked by
Aziz
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Aziz
Top achievements
Rank 1
Viktor Tsvetkov
Telerik team
Share this question
or