NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 52 53 54 55 56 … 93 Next »
Appearance Manager

 
  • 0 Vote(s) - 0 Average
Appearance Manager
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#11
2005-12-21, 06:56 AM
the thing is that for most composite images i use "@Filename" etc (even the background has "@CurrentLocation", "@PageNumbers" which makes skinning easier), so each time the file is drawn i have getnoncached... (whatever its called), since the normal method cant take hash params. so im forced to use
Code:
using(Image temp = skinHelper.getImageNonCached("Button",imageParams)){
g.DrawImage(temp,x,y,width,height);
}
which, in theory, will stop the memory problem but will take a little longer to draw since the composite image has to be reloaded.
i have started experimenting with a custom skinHelper that at first just loads the composite images with all drawText"@whatever" passed as "" (so they dont show up) and in the render method calls a custom method "DrawTextAttributes(ref image foreground, string imagename, hashtable params)"

Quote:Dont call GC.collect to force garbage collection. Its not recommended, and can really hurt performance.
the only time i have ever needed to force a call to gc.collect is when im ripping mp3 off of a cd since the cpu is running at 100% and the gc wont run otherwise. since a popupbox composite image "@Message" attribute has to be redrawn to display the status, once again using the "using" method.

if you know of an easier/better way of doing all this, please let me know Smile.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,626
Threads: 767
Joined: Nov 2003
#12
2005-12-21, 07:06 AM
Thats ok, even when you're doing this, with stuff that is changing all the time (@whatever), you should do the following.

In your render method, call SkinHelper.GetTemporaryBitmap() to get a bitmap that will be ultimately be returned to the calling method, then call SkinHelper.getNamedImageNonCached(myTempBitmap, false, Color.Transparent, "background", args). This version of get named image, effectively does all the drawing for you, but doesnt allocate a new bitmap. Instead it draws into a bitmap you supply, which in this case is a temporary one. It has argument to say if you want the background erased first, and if so, what colour to use.
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#13
2005-12-21, 07:19 AM
so will
Code:
SkinHelper.getNamedImageNonCached(myTempBitmap, false, Color.Transparent, "background", args).
keep all the other <DrawImage filename="button.png" ... /> in memory so they dont have to be reloaded all the time, and also me to pass params for all the "@whatever" attributes ? (i also pass images for "@Poster" etc).

also with the
Code:
SkinHelper.getTemporaryBitmapFromCache(int width,int height, int requiedInstance);
whats the last int for, and out whats the difffernce with this method and just calling
Image mybitmap = new Bitmap(width, height);
myself?

maybe i should have posted my original post in a seperate thread.....
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,626
Threads: 767
Joined: Nov 2003
#14
2005-12-21, 07:29 AM
Quote:so will
Code:
SkinHelper.getNamedImageNonCached(myTempBitmap, false, Color.Transparent, "background", args).
keep all the other <DrawImage filename="button.png" ... /> in memory so they dont have to be reloaded all the time, and also me to pass params for all the "@whatever" attributes ? (i also pass images for "@Poster" etc).
Yes, any image loaded from disk for a DrawImage statement is cached so that it doesnt need to be reloaded again in future.

Images passed in using the dynamic @image arguments are assumed to be dynamic, and are not cached.

Quote:also with the
Code:
SkinHelper.getTemporaryBitmapFromCache(int width,int height, int requiedInstance);
whats the last int for, and out whats the difffernce with this method and just calling
Image mybitmap = new Bitmap(width, height);
myself?
If you and ten other plugins call "new Bitmap(720,480)", then we have 10 rather large bitmaps sitting in memory. If you and those ten other plugins call getTemporaryBitmapFromCache() during the render method, then there is only ever the one bitmap allocated, which results in much better memory usage.

That last "int" is a little difficult to explain, but it is an instance number. If in the same render() method you need a second one of these large bitmaps, then ask for instance 2. I'll give a bit better description of this when I do a write up, but hopefully this makes sense?
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#15
2005-12-21, 07:38 AM
ok thanks sub im pretty sure i get it now Smile
psycik
Offline

Posting Freak

Posts: 5,210
Threads: 424
Joined: Sep 2005
#16
2005-12-21, 07:46 PM
sorry to hijack this thread and get into nuts and bolts of plugin writing.

Sub, is this new bitmap, caching type stuff, what you're looking at putting in your guide lines document you said you might be writing??

If not, I think a new thread on this sort of stuff would be useful.
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#17
2005-12-23, 12:24 AM
sub can you add another method like so
Code:
skinHelper.getNamedImageNonCached(Image composite, bool fill, Color color, string name, Rectangle Bounds, Hashtable imageParams);
the only addition is the "Rectangle Bounds" part, that way instead of needing to create a say 140x36 image for a button, which will be painted to a background after its created, i can just paint it to the background in one go. and saving memory Smile also would help with coding (far less changes to my code would have to be made this way).
reven
Offline

Posting Freak

Posts: 5,782
Threads: 396
Joined: Sep 2004
#18
2005-12-23, 12:28 AM
oh and the bounds thing just tells the skinhelper where on the passed image to draw the requested compositeimage Smile
Old Dog
Offline

Posting Freak

Posts: 1,083
Threads: 99
Joined: Jul 2005
#19
2005-12-29, 07:30 PM
The first version of the Appearance Manager Plugin is out so I am at point where I can think more clearly about extending it for general usage.

As I have said, I believe the first step is to improve the skinning facilities in general. I have a few suggestions along these lines. Please realize that I do not know the internal structure of GBPVR so some of these ideas may simply be too expensive. In fact my first suggestion may be such a case.

  1. An Alias directive. The syntax may be something like <Alias name="MyFavoriteFont" value="Tahoma"/>. Whenever the SkinHelper encounters text it does not reconize it would check to see if it were an Alias for something more understandable (recursively?).

  2. Make it possible to define an element in terms of another similar element, for example:
    • <TextStyle name="NormalText" color="Black" typeFace="Tahoma" size="12" style="regular"/>
    • <TextStyle name="SelectedText" textStyle="NormalText" size="14" style="bold"/>

    • Or combining items 1 & 2, <TextStyle name="NormalText" color="Black" typeFace="MyFavoriteFont" size="12" style="regular"/>...
  3. Make it possible to include xml files in xml files. For example, it would be benificial to define identical popups in one file and simply include them when needed.
Learning new tricks!
Visit Plain Jane's Collection
Old Dog
Offline

Posting Freak

Posts: 1,083
Threads: 99
Joined: Jul 2005
#20
2005-12-29, 08:28 PM
sub Wrote:As solution, you'll notice there is a SkinHelper.GetTemporaryBitmap() method which can be used to give you a cached bitmap. The idea is you'd call this during your plugin's Render() method, and return the image at the end of the method. You dont need dispose of the image or anything. It'll automatically be reused next time someone Render()s.

I just implemented the GetTemporaryBitmap() method and it worked fine. Then I realized I didn't know the syntax for returning it.

What is the syntax for returning a temporary bitmap and better still where can I find the documentation?

Thanks,
David
Learning new tricks!
Visit Plain Jane's Collection
« Next Oldest | Next Newest »

Users browsing this thread: 2 Guest(s)

Pages (11): « Previous 1 2 3 4 5 … 11 Next »
Jump to page 


Possibly Related Threads…
Thread Author Replies Views Last Post
  Plugin Manager imilne 20 7,405 2011-07-12, 09:35 PM
Last Post: imilne
  What I don't like about Appearance Manager! Old Dog 0 1,319 2006-07-08, 05:46 PM
Last Post: Old Dog
  Appearance Manager Documentation Thread. Fatman_do 14 6,020 2006-05-12, 05:18 PM
Last Post: Fatman_do
  CDK Scheduler (External Recording Manager) KingArgyle 1 1,382 2005-02-08, 06:45 PM
Last Post: KingArgyle
  External Recordings Manager KingArgyle 70 16,610 2005-01-31, 08:37 PM
Last Post: KingArgyle
  Extreme Movie Manager joche 2 1,709 2005-01-06, 09:39 PM
Last Post: joche

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

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

Linear Mode
Threaded Mode