0

Destroying Image Objects

Hi @ll,

I got a problem concerning the performance of some TVs.
I program a Widget with a lot of Images. A Image will load if you focus a Button.
But If I focus too much Buttons the performance of the TV is rapidly going down. Means, a focus to the next button needs 10 secs.
I just overlay the old image with a new image.
So the question is: Can I destroy the Image which is under the new Image?
I believe I can reach a better performance if I destroy the old image.

by
6 Replies
  • QUOTE (Rainer @ Oct 23 2009, 03:54 AM) <{POST_SNAPBACK}>
    Hi @ll,

    I got a problem concerning the performance of some TVs.
    I program a Widget with a lot of Images. A Image will load if you focus a Button.
    But If I focus too much Buttons the performance of the TV is rapidly going down. Means, a focus to the next button needs 10 secs.
    I just overlay the old image with a new image.
    So the question is: Can I destroy the Image which is under the new Image?
    I believe I can reach a better performance if I destroy the old image.


    Its hard to understand what actually going wrong without any code BTW ,

    FYI:

    You can destroy your image object by using parentObj.removeChild(yourImgObj), or you can use the same Image object but pass to it new image url.
    0
  • QUOTE (vova.leskiv @ Oct 23 2009, 04:38 AM) <{POST_SNAPBACK}>
    Its hard to understand what actually going wrong without any code BTW ,

    FYI:

    You can destroy your image object by using parentObj.removeChild(yourImgObj), or you can use the same Image object but pass to it new image url.


    Tested already the new image url with same Image object. But this doesn't help. The performance is still going down.

    Code:
    CODE
    		var ContainerText = new KONtx.element.Container({
    styles: {
    width: KONtx.utility.scale(40),
    height: KONtx.utility.scale(26),
    hAlign: 'left',
    vAlign: 'top',
    }
    }).appendTo(this);

    new KONtx.element.Image({
    src: "image/MenuBackButton.jpg",
    styles: {
    height: ContainerText.height,
    width: ContainerText.width,
    //hAlign: 'center'
    },
    }).appendTo(ContainerText);

    var backButton = new KONtx.control.TextButton({
    label: '',
    styles: {
    width: KONtx.utility.scale(40),
    height: KONtx.utility.scale(26),
    hAlign: 'left',
    vAlign: 'top',
    hOffset: 0,
    },
    events: {
    onFocus: function(event) {
    new KONtx.element.Image({
    src: "image/Movies.jpg",
    styles: {
    height: topContainerMovies.height,
    width: selfmovies.width,
    valign: 'top',
    },
    }).appendTo(topContainerMovies);
    },
    onSelect: function(event) {
    KONtx.application.loadView("mainmenu");
    }
    }
    }).appendTo(this);

    ......................................


    cellCreator: function() {

    cell = new KONtx.control.GridCell({
    styles: this.getCellDimensions(),
    events: {
    onFocus: function(event) {
    moviecells = this.getCellIndex();
    movieside = selfmovies.ButtonGrid.getCurrentPage();
    var gesamt = moviecells + 6*movieside + 1;
    trailername = movietrailers[(moviecells + 6*movieside)];
    new KONtx.element.Image({
    src: "http://192.168.0.228/Widgets//Mediaportal/Movies/Header/Mov"+gesamt+"Head.jpg",
    styles: {
    width: this.width,
    height: topContainerMovies.height,
    valign: 'center',
    hAlign: 'center',
    },
    }).appendTo(topContainerMovies);
    ........................
    0
  • As i get right understand you want to see only last focused image in topContainerMovies? If that's right you need create image only one time in your createView() method and in createCell() just set new src to it.
    0
  • I wonder if you really want to be creating and images via an onFocus events.

    Perhaps instead you should create all the images when you update the view and set them to not be visible. Then when you focus on the cell display or hide the images, right now everytime you focus on a cell you're going to create a new Image so you are going to just stack the same image over image over image..... This can't be good.
    0
  • QUOTE (Mike R. @ Oct 23 2009, 08:43 AM) <{POST_SNAPBACK}>
    I wonder if you really want to be creating and images via an onFocus events.

    Perhaps instead you should create all the images when you update the view and set them to not be visible. Then when you focus on the cell display or hide the images, right now everytime you focus on a cell you're going to create a new Image so you are going to just stack the same image over image over image..... This can't be good.


    That's why I am asking.
    Yes, it's not good. ^^
    As I mentioned the loading times are annoying.

    But I tested the same situation with setting up a new image src to an image var.
    Nothing changed. The loading times were simply too long.
    0
  • The code was difficult to follow in this thread, but I hope this helps:

    You shouldn't be "creating a new image object" ever once you have created one for that view. When you need to change the image, you call <image>.setSource(<newURL>);
    0

Recent Posts

in Design / Interaction - Yahoo! TV Widgets