Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Assets [RELEASED] Image Cropper - multiplatform image cropping solution with oval mask support

Discussion in 'Works In Progress' started by yasirkula, Apr 15, 2018.

  1. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,721
    I'm guessing you need to add
    markTextureNonReadable = false,
    to Settings parameter.
     
  2. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    141
    Thats what i did.
    Texture2D _texture = NativeGallery.LoadImageAtPath(_path, -1, false, false);
     
  3. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,721
    I mean the ImageCropper.Settings object.
     
  4. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    141
    Ahhh i see, where it says
    result.Apply( false, MarkTextureNonReadable );


    make it
    result.Apply( false, false );
     
  5. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,721
    Code (CSharp):
    1. settings: new ImageCropper.Settings()
    2. {
    3.     ovalSelection = ovalSelection,
    4.     autoZoomEnabled = autoZoom,
    5.     imageBackground = Color.clear,
    6.     selectionMinSize = new Vector2(512,512),
    7.     selectionMaxSize = new Vector2(512,512),
    8.     markTextureNonReadable = false,
    9. },
     
  6. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    141
    I just changed it in the ImageCropper.cs where is says result.apply. that worked great. thanks Yas
     
    yasirkula likes this.
  7. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    121
    I like the way you can choose the size and resize the final result. Is there a way to scale it to 2 different sizes, 2 textures? In my app I need to get 2 textures, one is half the size, and the second is very low (30x30). Or is there a way to use your scaling function by a given texture? So far I do it manually, getting the cropped image, and then use TextureScale.Bilinear, but the quality is very bad when scaling to 30x30, it gets blurry. I think your scaling function is better
     
  8. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,721
    I don't actually have a resize algorithm. I just create a RenderTexture of specified size and the camera renders to that texture. I think the easiest solution here would be to modify ImageCropper.Crop function so that after the "
    Texture2D result = CropSelection();
    " line, it also calls "
    Texture2D resultSmall = CropSelection(30,30);
    " and then passes that texture to the callback function, as well. You'll need to change the delegate as follows:
    public delegate void CropResult(bool result, Texture originalImage, Texture2D croppedImage, Texture2D croppedImageSmall);
     
    swifter14 likes this.
unityunity