Skip to content

why decode image after [UIImage initwithData:] ? #602

Closed
@limboy

Description

@limboy
- (UIImage *)diskImageForKey:(NSString *)key
{
    NSData *data = [self diskImageDataBySearchingAllPathsForKey:key];
    if (data)
    {
        UIImage *image = [UIImage sd_imageWithData:data];
        image = [self scaledImageForKey:key image:image];
        image = [UIImage decodedImageWithImage:image];
        return image;
    }
    else
    {
        return nil;
    }
}

what's the benefit of this approach instead of using CGImageSourceCreateWithData(CFDataRef data, CFDictionaryRef options) directly ?

Activity

andrey-krukovskiy

andrey-krukovskiy commented on Mar 4, 2014

@andrey-krukovskiy

👍
Current solution uses much memory, and we experienced problems with it. Seems that it may results in crashes due to huge memory consumption in some cases.
I found that current solution was introduced by PR #33. But when we replace content of decodedImageWithImage: method with just return image; it working not worse than early.

phamquy

phamquy commented on Mar 10, 2014

@phamquy

i have the same question, but as stated in #33, "undecoded" will cause "visible delay". I think it would be better solution if we can opt out "forceDecode" option.
@andrey-krukovskiy what do you meant by "working not worse than early"?

andrey-krukovskiy

andrey-krukovskiy commented on Mar 10, 2014

@andrey-krukovskiy

I meant that no some visible delays were for me. May be for last 2 year performance of devices were increased, or may be I just miss it. I'm not sure in it, because I'm not performed special comparison for it.

added this to the Future milestone on Jun 17, 2014
mythodeia

mythodeia commented on May 29, 2015

@mythodeia
Contributor

now there is the option
shouldDecompressImages available for both
SDImageCache & SDWebImageDownloader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @limboy@bpoplauschi@andrey-krukovskiy@phamquy@mythodeia

        Issue actions

          why decode image after [UIImage initwithData:] ? · Issue #602 · SDWebImage/SDWebImage