Giter VIP home page Giter VIP logo

Comments (4)

freeslur avatar freeslur commented on September 27, 2024

Hi.
I solved a second problem(cannot free from memory), but I have still a first problem(memory size).
Please, help.

from glview.

nicklockwood avatar nicklockwood commented on September 27, 2024

Are you loading the animation images by passing an array of strings to the GLImageView, or are you passing an array of images that you've loaded using GLImage?

Also, what format are your images (e.g. PNG, PVR) and how are you loading them?

from glview.

freeslur avatar freeslur commented on September 27, 2024

My code ::

NSMutableArray *_frames = [[NSMutableArray alloc] initWithCapacity:1];
GLImageView *_imageView = [[GLImageView alloc] initWithImage:[[GLImage alloc] initWithContentsOfFile:imagePath]];
....
[self loadWildCardFiles:_imageSource inDirectory:_directory toFrames:_frames];
_imageView.animationDuration = _duration;
_imageView.animationRepeatCount = _repeatCount;
_imageView.animationImages = _frames;
[_imageView startAnimating];


- (void)loadWildCardFiles:(NSString *)source inDirectory:(NSString *)directory toFrames:(NSMutableArray *)frames
{
    NSString *wildCardPath = [directory stringByAppendingPathComponent:source];
    NSString *targetSource = [wildCardPath lastPathComponent];
    NSString *targetDirectory = [wildCardPath stringByDeletingLastPathComponent];

    NSArray *components = [targetSource componentsSeparatedByString:@"*"];

    NSString* file;
    NSDirectoryEnumerator* enumerator = [[NSFileManager defaultManager] enumeratorAtPath:targetDirectory];
    while (file = [enumerator nextObject])
    {
        NSUInteger lastRange = 0;
        BOOL found = YES;
        for(NSUInteger i=0; i<components.count; i++)
        {
            NSString *component = [components objectAtIndex:i];
            if(component.length > 0)
            {
                NSRange range = [file rangeOfString:component];
                if((range.length > 0) && ((range.location == lastRange) || (i > 0 && range.location > lastRange)))
                    lastRange = range.location + range.length;
                else
                {
                    found = NO;
                    break;
                }
            }
        }
        if(!found || (lastRange < file.length))
            continue;
        NSString *path = [targetDirectory stringByAppendingPathComponent:file];
        GLImage *image = [GLImage imageWithContentsOfFile:path];
        if(image)
            [frames addObject:image];
    }
}

image format : png(and pvr is same)

And I just changed from GLImage to UIImage and from GLImageView to UIImageView, checked memory.

from glview.

nicklockwood avatar nicklockwood commented on September 27, 2024

Sorry, I forgot to follow up on this. Basically to reduce memory, store the array of image paths in your frames array, not the array of GLImages, like this:

    NSString *path = [targetDirectory stringByAppendingPathComponent:file];
    [frames addObject:path];

For this to work fast enough for real-time, you will probably also need to use PVR images instead of PNG, but you can try it with PNG (it may be fast enough).

from glview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.