Coder Social home page Coder Social logo

Retina (@2x) image loading about nimbus HOT 5 CLOSED

grgcombs avatar grgcombs commented on August 19, 2024
Retina (@2x) image loading

from nimbus.

Comments (5)

jverkoey avatar jverkoey commented on August 19, 2024

Do you mean loading retina images from disk? I think I may have overlooked this. The disk loader doesn't check for @2x prefixes on retina devices. This is trivial to add though, so if someone doesn't beat me to it I can get this fixed this week.

  • Jeff

On 2011-07-17, at 3:58 PM, [email protected] wrote:

Looking through the network image sources, I'm trying to figure out if there's already a mechanism to handle retina image scales. I got excited when I saw the scale parameters, but it looks like it's for something else, related to aspect ratios.

Is there anything special that needs to happen in order to load retina images vs. standard images when available (and the device is retina capable)?

Reply to this email directly or view it on GitHub:
#16

from nimbus.

grgcombs avatar grgcombs commented on August 19, 2024

Yeah ... Let's say I know I'm running on an iPhone 4 and have a retina display ... I could request @2x files from the server (maybe the lib would catch file not found from the response, drop the @2x appendage, and resend the file request automatically). Then set up the UIImage scale property accordingly based on what it found.

g

Sent from my iPad

On Jul 17, 2011, at 4:42 PM, [email protected] wrote:

Do you mean loading retina images from disk? I think I may have overlooked this. The disk loader doesn't check for @2x prefixes on retina devices. This is trivial to add though, so if someone doesn't beat me to it I can get this fixed this week.

  • Jeff

On 2011-07-17, at 3:58 PM, [email protected] wrote:

Looking through the network image sources, I'm trying to figure out if there's already a mechanism to handle retina image scales. I got excited when I saw the scale parameters, but it looks like it's for something else, related to aspect ratios.

Is there anything special that needs to happen in order to load retina images vs. standard images when available (and the device is retina capable)?

Reply to this email directly or view it on GitHub:
#16

Reply to this email directly or view it on GitHub:
#16 (comment)

from nimbus.

jverkoey avatar jverkoey commented on August 19, 2024

Ah, I see.

The way the network image view works right now, it works best for retina displays when you request images that are too large and must be scaled down. The scaling code you've probably seen here:

https://github.com/jverkoey/nimbus/blob/master/src/networkimage/src/NIHTTPImageRequest.m#L401

will create a higher resolution image from the source image on retina displays.

For example, say I'm loading a 500x500 image from the network and displaying it in a 100x100 image. On a non-retina display, the resulting image would be 100x100, but on a retina display the image would be 200x200 with a scale of 2.0.

From the sounds of it, this doesn't solve your particular use case, where you'd like to fetch a pre-created @2x image from the network. This is an interesting feature request. Given the intended use case for the network image view, I think that searching for the @2x file would be an optional feature that would be off by default, but I wouldn't be against adding it at all.

from nimbus.

grgcombs avatar grgcombs commented on August 19, 2024

Cool!

from nimbus.

cuu avatar cuu commented on August 19, 2024

I meet the similar problem
NIPhotoScrollView got problem with retina screen, the image in PhotoScrollView is smaller than in the same of iphone screen without retina.

so

  • (void)minAndMaxScaleForDimensions: (CGSize)dimensions
    boundsSize: (CGSize)boundsSize
    photoSize: (NIPhotoScrollViewPhotoSize)photoSize
    minScale: (CGFloat *)pMinScale
    maxScale: (CGFloat *)pMaxScale {
    NIDASSERT(nil != pMinScale);
    NIDASSERT(nil != pMaxScale);
    if (nil == pMinScale
    || nil == pMaxScale) {
    return;
    }

    CGFloat minScale = [self scaleForSize: dimensions
    boundsSize: boundsSize
    useMinimalScale: YES];

    // On high resolution screens we have double the pixel density, so we will be seeing
    // every pixel if we limit the maximum zoom scale to 0.5.
    // If the photo size is unknown, it's likely that we're showing the loading image and
    // don't want to shrink it down with the zoom because it should be a scaled image.

    CGFloat maxScale = ((NIPhotoScrollViewPhotoSizeUnknown == photoSize)
    ? 1
    : (1.0f * NIScreenScale()));

I changed to (1.0f * NIScreenScale())); from (1.0f / NIScreenScale()));

Hope this can be helpful

from nimbus.

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.