MonoTouch: Getting an Image out of ALAssetsLibrary.AssetForUrl

只愿长相守 提交于 2019-12-23 10:39:50

问题


In MonoTouch:

I am putting in an image from the Camera into the PhotoAlbum:

ALAssetsLibrary library = new ALAssetsLibrary();
library.WriteImageToSavedPhotosAlbum(photo.CGImage, meta, (assetUrl, error) => {
    library.AssetForUrl(assetUrl, GotAsset, FailedGotAsset);
});

The Photo is all there, works well.

On the delegate GotAsset I am attempting to get out the image, but only the Thumbnail is there. Where is the image?

    void GotAsset(ALAsset asset)
    {
         //asset has only thumbnail info???
    }

Here's what the asset looks like:


回答1:


You're not seeing, at runtime, every properties on devices because, by default, the (managed) linker is enabled (Link SDK). This will remove any code, including properties, your application is not using (and saves tons of KB and deployment times).

You can try to debug this on the simulator (which default to Don't link) by adding your own assets (in the simulator). Another way is to, temporarily, disable the linker on your device builds.

In either cases your ALAsset should be showing all documented properties.




回答2:


Based on @Poupou's help here's the code I added to make it work:

    void GotAsset(ALAsset asset)
    {
        ALAssetRepresentation rep = asset.DefaultRepresentation;
        var iref = rep.GetImage();
        if(iref!=null)
            DoStuffWithUIImage(UIImage.FromImage(iref));
    }


来源:https://stackoverflow.com/questions/12361425/monotouch-getting-an-image-out-of-alassetslibrary-assetforurl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!