Titanium Community Questions & Answer Archive

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

[mobile] error label's backgroundImage : '../images/g.png'

I do not know why this error.
print to Titanium monitor

WARN] the 'url' property on ImageView has been deprecated. Please use 'image' instead
[WARN] the 'url' property on ImageView has been deprecated. Please use 'image' instead
Mon Nov 29 11:05:01 localhost test[799] <Error>: CGContextConcatCTM: invalid context 0x0
Mon Nov 29 11:05:01 localhost test[799] <Error>: CGContextSetInterpolationQuality: invalid context 0x0
Mon Nov 29 11:05:01 localhost test[799] <Error>: CGContextDrawImage: invalid context 0x0
Mon Nov 29 11:05:01 localhost test[799] <Error>: CGBitmapContextCreateImage: invalid context 0x0
Mon Nov 29 11:05:01 localhost test[799] <Error>: CGContextConcatCTM: invalid context 0x0
Mon Nov 29 11:05:01 localhost test[799] <Error>: CGContextSetInterpolationQuality: invalid context 0x0
Mon Nov 29 11:05:01 localhost test[799] <Error>: CGContextDrawImage: invalid context 0x0
Mon Nov 29 11:05:01 localhost test[799] <Error>: CGBitmapContextCreateImage: invalid context 0x0
Mon Nov 29 11:05:01 localhost test[799] <Error>: CGContextConcatCTM: invalid context 0x0
Mon Nov 29 11:05:01 localhost test[799] <Error>: CGContextSetInterpolationQuality: invalid context 0x0
Mon Nov 29 11:05:01 localhost test[799] <Error>: CGContextDrawImage: invalid context 0x0
Mon Nov 29 11:05:01 localhost test[799] <Error>: CGBitmapContextCreateImage: invalid context 0x0
[WARN] the 'url' property on ImageView has been deprecated. Please use 'image' instead

the code on js


var curWin =  Ti.UI.currentWindow;

var barView = Titanium.UI.createView({
    height:200,
    width:285
//    backgroundColor:'#d1d1d1'
});

var bar_Label = Titanium.UI.createLabel({
    backgroundImage: "../images/g.png",
    top: 30,
    left: 20,
    height:10,
    width:55
});
barView.add(bar_Label);

curWin.add(barView);

Can anyone help with this?

Thanks.

— asked November 29th 2010 by becca zhang
  • image
  • label
  • view
0 Comments

2 Answers

  • Becca,

    First, try changing the path to the backgroundImage to eliminate the ../ and make it just 'images/g.png' instead. The path should always be how to find the image relative to the Resources folder.

    In the case of the Kitchen Sink app, most windows are inside the examples folder, so they need to prepend ../ to the path to get back to the Resources folder (from examples) but unless your window's *.js is in a subfolder of Resources you don't need to do the same thing.

    Second, in my experience it has not worked to comment out a property within a { … } group as you did with backgroundColor in barView. Move that line to just after the }); if you want to keep it around to shift back into the barView later.

    — answered November 29th 2010 by Doug Handy
    permalink
    0 Comments
  • Becca

    The errors seem to suggest that you are using the url rather than the image property for Titanium.UI.ImageView somewhere in your code. I can't see it in the code you have pasted here, but it may be worth checking the rest. This won't cause the images to fail, but at some point in the future the url property will be dropped completely so it's worth changing over now.

    Your image paths need to be relative to the context from which they are being loaded. For ios, currently you need to use relative paths, but in android absolute paths are possible.

    So, with your code:

    backgroundImage: "../images/g.png",
    

    This will work if your code is in a subdirectory of Resources, for example, Resources&#x2F;myCode&#x2F;myScript.js which is loading your images from Resources&#x2F;images&#x2F;g.png.

    Commenting out properties like this:

    //  backgroundColor:'#d1d1d1'
    

    …doesn't cause any problems for me, at least on android. You have remembered to remove the preceding comma, which some people forget to do and so causes syntax errors.

    Hope this helps

    — answered November 29th 2010 by Paul Dowsett
    permalink
    2 Comments
    • remove the ../, but not found this pic

      — commented November 30th 2010 by becca zhang
    • clean ur build and check..

      — commented January 31st 2013 by ganesh m
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.