NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 62 63 64 65 66 … 93 Next »
"Approved" way of having a changing a screen value

 
  • 0 Vote(s) - 0 Average
"Approved" way of having a changing a screen value
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#1
2006-01-06, 12:08 AM
Hi

I just found out that the way I way updating a time value (every second) was causing a memory leak.

I was updating the value by updating an arg of a named image.

This in turn caused a fairly large memory leak.

How should I be doing something like this??

As a work around I have isolated this element and am now using a drawstring method.
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#2
2006-01-06, 12:22 AM
i do it this way,

create a background image (the complete image of whats not changing, might be hard to do sometimes, but quicker to draw).
and use the method
Code:
Image temp = skinHelper.getTemporaryBitmapFromCache(width,height,instance);
Graphics.FromImage(temp ).Clear(Color.Transparent);
that way you wont be creating a new bitmap at each repaint, instead you'll be using the same one, and just clearing it.

instance is a tricky thing, sub hasnt fully explained this, im not sure if the width/height is taken into account when you are referring to an instance, for a background using "0" is pretty safe though, if you start seeing funny effects, just experiment with a higher number.

you can also use this
Code:
skinHelper.getNamedImageNonCached(temp,false, Color.Transparent,"CompositeImageWanted",new Hashtable());
that will draw the requested composite image into the "temp" image passed, instead of returning a new bitmap.
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#3
2006-01-06, 12:37 AM
Hmm, have to try and figure all that out.

I never really understood this when I saw it in some other thread how this temporary image stuff worked.

Code:
Image temp = skinHelper.getTemporaryBitmapFromCache(width,height,instance);
Graphics.FromImage(temp ).Clear(Color.Transparent);

in this, what is it actually trying to draw? Like normally if you're using a cached (composite Image) you call it by name.


BTW just saw your new site (from your avatar)....pretty.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,740
Threads: 767
Joined: Nov 2003
#4
2006-01-06, 12:45 AM
Quote:
Code:
Image temp = skinHelper.getTemporaryBitmapFromCache(width,height,instance);
Graphics.FromImage(temp ).Clear(Color.Transparent);

in this, what is it actually trying to draw?
Its not drawing anything. Its just giving you a temporary bitmap that you can then use to draw whatever you need to. When you've finished with this bitmap, it'll be reused by other areas of the application. This is more efficent that every plugin allocating there own large screen bitmaps.

Quote:Like normally if you're using a cached (composite Image) you call it by name.
Yes, named images are also cached within the skin helper. I added this temporary bitmap stuff when I started to recognise a most plugins were allocating large screen bitmaps which they draw their screens into. Each of these screen bitmaps ends up using about 2MB of RAM, so its good to try and share them around and reuse where possible.
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#5
2006-01-06, 12:51 AM
if you are using a lot of <DrawText text="@Whatever".../> (that tag is wrong but you know what i mean), in your skin, then your probably calling this a lot
skinHelper.getImageNonCached("compositeimage", imageparams);
that is creating a new bitmap every call, which is bad.

using those two lines you quote, that allows you to then use
Code:
skinHelper.getNamedImageNonCached(temp,false, Color.Transparent,"CompositeImageWanted",new Hashtable());
that will paint the new composite image over the old one, so you're not creating a new bitmap (which is the big memory issue).

these two lines
Code:
Image temp = skinHelper.getTemporaryBitmapFromCache(width,height,instance);
Graphics.FromImage(temp ).Clear(Color.Transparent);
arent drawing anything, its just getting a temp bitmap from cache (one thats already created) and the second line is just clearing it so its like a fresh bitmap.
but using this means you canNOT call temp.Dipose(), otherwise you'll get an error the next time you use the same temp bitmap.
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#6
2006-01-06, 01:04 AM
So, excuse me for being really thick, but I feel it....

At the moment, I don't know where I got the method from. But in my IMenuTask.render I do the following:

Code:
Image backgroundPicture = skinHelper.getNamedImage("Background", args);
Graphics.FromImage(backgroundImage).DrawImage(backgroundPicture, 0,0,720,480);
            
// Create the foreground image
Graphics g = Graphics.FromImage(foregroundImage);
g.Clear(Color.Transparent);

So this would be what you don't want me doing??

And then (you'll probably both be wanting to wring my neck at this stage) for most of my screens, I pass the Graphics (g) from and that is what I draw images on. Like...

Code:
tempImage = skinHelper.getNamedImage(imagename, itemArgs);

// Draw the item
g.DrawImage(tempImage, ListBoxLocation.StartX , ListBoxLocation.StartY +(i-firstVisibleInList)*ListBoxLocation.Spacing);

So is this the REALLY WRONG way of doing things???
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#7
2006-01-10, 09:21 PM
Ok, so i managed to grow a brain and figure it out.

I'd been doing most of my work based on BlueMCE where all of the CompositeImages are image based (i.e contain a draw image as it's primary element) and these work fine. But one problem area I have found is relating to DrawRoundRect.

Here's what I've got that works for an image based compositeimage
Code:
tempImage = skinHelper.getTemporaryBitmapFromCache(boxWidth,boxHeight,1);
Graphics.FromImage(tempImage).Clear(Color.Transparent );

This works fine for something like:
Code:
<CompositeImage name="PlayListImage" size="460,280">
    <DrawImage filename="..\resources\list_background_focus.png" loc="0,0" size="470,280"/>
</CompositeImage>

but if the skin does this:

Code:
<CompositeImage name="ListImage" size="410,260">
    <DrawRoundedRect loc="4,4" size="402,250" radius="7" borderWidth="4" borderColor="White" fillColor="Black"/>        
</CompositeImage>

then it doesn't, and I have to use:
Code:
tempImage = skinHelper.getNamedImage(listPrefix +"ListImage");
instead.

Is this by design, a bug??

cheers
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#8
2006-01-10, 09:25 PM
Aha, don't worry, the brain grew a bit more and I figured it out......helped re-reading this post though.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Changing the recording priority on recurring recordings cbgifford 4 3,840 2014-08-17, 03:13 PM
Last Post: Kiwi
  Multiple lists like in Search Screen cncb 7 3,332 2012-08-08, 09:11 PM
Last Post: cncb
  How to prevent default screen background? cncb 28 8,558 2012-05-16, 08:28 PM
Last Post: ACTCMS
  Concatenate Name and Subtitle in Pending Recordings Screen Northpole 0 1,211 2011-09-20, 02:54 PM
Last Post: Northpole
  Settings config screen for class IEventNotification plugin imilne 9 3,589 2011-09-17, 06:06 PM
Last Post: sub
  Changing recording schedules on the fly. mvallevand 2 1,947 2011-09-06, 03:30 AM
Last Post: BrettB
  @channelIcon not available in all recording screen options Northpole 2 1,821 2011-07-29, 04:59 PM
Last Post: Northpole
  A list of changing images McBainUK 1 1,868 2011-06-21, 04:36 PM
Last Post: sub
  Skin question - how to centre a list UiList control on screen? McBainUK 2 1,877 2011-02-17, 08:46 AM
Last Post: McBainUK
  Changing skin font or colour mvallevand 30 7,135 2010-07-23, 02:20 PM
Last Post: whurlston

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode