Upload to Server

7 posts, 0 answers
  1. Aziz
    Aziz avatar
    32 posts
    Member since:
    Sep 2011

    Posted 19 Mar 2012 Link to this post

    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?
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 19 Mar 2012 Link to this post

    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 >>
  3. DevCraft banner
  4. Aziz
    Aziz avatar
    32 posts
    Member since:
    Sep 2011

    Posted 19 Mar 2012 Link to this post

    When i attempt to run your solution using a jpg file from my computer i get IndexOutOfRangeException on line 36 of MySaveCommand.cs
  5. Aziz
    Aziz avatar
    32 posts
    Member since:
    Sep 2011

    Posted 19 Mar 2012 Link to this post

    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?
  6. Viktor Tsvetkov
    Admin
    Viktor Tsvetkov avatar
    382 posts

    Posted 22 Mar 2012 Link to this post

    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 >>
  7. Aziz
    Aziz avatar
    32 posts
    Member since:
    Sep 2011

    Posted 22 Mar 2012 Link to this post

    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?
  8. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 22 Mar 2012 Link to this post

    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 >>
Back to Top
DevCraft banner