Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

scaled images in scrollview

I'm creating an alternative to the coverflowview using scrollable views. All's working well, except the image scaling issue.
The images are being pulled from various rss feeds (flickr, etc) so can be of varying resolutions.

If I don't specify height and width parameters in my imageview, all images show up: the small ones show up small, and the large ones full size, so are off the edge of the screen.

If I specify ONE parameter (height, or width) the LARGE ones scale down proportionately and show up fine, but the smaller ones give me this error for each image, and no image shows up:

Sat Nov 20 11:31:42 drhmini.local Raoul and The Big Time[8012] <Error>: CGContextConcatCTM: invalid context 0x0
Sat Nov 20 11:31:42 drhmini.local Raoul and The Big Time[8012] <Error>: CGContextSetInterpolationQuality: invalid context 0x0
Sat Nov 20 11:31:42 drhmini.local Raoul and The Big Time[8012] <Error>: CGContextDrawImage: invalid context 0x0
Sat Nov 20 11:31:42 drhmini.local Raoul and The Big Time[8012] <Error>: CGBitmapContextCreateImage: invalid context 0x0

If I specify BOTH height and width tags, all images show up scaled to fit the specified dimensions.

(canScale=true in all cases, tested on the iphone emulator only, built using 1.4.2, and ios 4.0)

So, there's no good way, currently for me to consistently get images fitting properly on the screen…!

any ideas?
David

— asked November 20th 2010 by david hoare
  • image
  • scale
2 Comments
  • Please would you state your mobile platform? Thanks

    — commented November 20th 2010 by Paul Dowsett
  • Sorry, just spotted it - ignore previous request! ;)

    — commented November 20th 2010 by Paul Dowsett

1 Answer

  • The 'invalid context 0x0' errors appear to persist in SDK 1.5 on IOS 4.2. Creating a view and adding the label and a button to contain the image seems to be a workaround:

    view = Ti.UI.createView({...});
    button = Ti.UI.createButton({...});
    label = Ti.UI.createLabel({...}); // no backgroundColor
    view.add(button);
    view.add(label);
    

    Hope this helps :-)

    — answered January 14th 2011 by Jim K
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.