Old 16th November 2008, 12:54   #1
clementj
Senior Member
 
Join Date: Oct 2006
Posts: 356
Find the actual width of an image?

I wish to have optional images added to my skin, and I need to know the size of the image. The user would supply the images as they wish. So I used the following code.
In the elements file:
<bitmap id="player.picture" file="c:\Program Files\Winamp\picture.png" gammagroup="DisplayElements"/>

In the main file:
<layer
id="player.user.picture"
x="250" y="3"
tile="1"
image="player.picture"
/>

and in the appropriate Maki file:

Global layer GroupLogo, userpicture;
.....
Global int GroupLogoW, userPictureW, GroupLogoX;
.....
userPicture = frameGroup.findObject("player.user.picture");
.....
userPictureW = stringtointeger(userpicture.getXMLParam("w"));
System.debugString("logo w,picture w "+integertostring(grouplogow)+", "+integertostring(userpicturew),9);

I would have assumed that since I did not define the size of the image that Winamp would pick it up from the actual image which is 299x37 in size. But the value returned is 200. If I have a smaller image 44x30 the value returned is zero. Obviously Winamp has the information because the image is displayed correctly without an intervention from Maki. For some reason the information is not available.

Is this a bug, oversight, or feature? Or am I doing something wrong here?
clementj is offline   Reply With Quote
Old 23rd November 2008, 13:45   #2
clementj
Senior Member
 
Join Date: Oct 2006
Posts: 356
Since nobody seems to know the answer to this question, or wants to reply to it, should it be posted elsewhere?

I think this is an oversight in the code, or it should be classified as a bug!!!!
clementj is offline   Reply With Quote
Old 23rd November 2008, 14:29   #3
Michgelsen
Major Dude
 
Michgelsen's Avatar
 
Join Date: Oct 2003
Location: Netherlands
Posts: 1,416
It has been a very long time since I did any skinning, but obviously if you don't define a "w" in your xml, you can't retreive it by using getXMLParam("w").

What about this function?
PHP Code:
/**
 getWidth()

 Get the width of the object, in pixels.

 @ret The width of the object.
*/
extern int GuiObject.getWidth(); 
Or maybe this one?
PHP Code:
/**
 onResize()

 Hookable. Event happens when the object is about
 to be resized.

 @param  x   The X position where the object will be anchored.
 @param  y   The Y position where the object will be anchored.
 @param  w   The width the object will have.
 @param  h   The height the object will have.
*/
extern GuiObject.onResize(int xint yint wint h); 
What's up with the edit function by the way? If I edit for a second time, the previous changes are lost.
Michgelsen is offline   Reply With Quote
Old 23rd November 2008, 18:29   #4
pjn123
Major Dude
 
pjn123's Avatar
 
Join Date: Jan 2006
Location: /\/¯¯¯¯¯\/\ , South-Africa
Posts: 1,030
@Michgelsen - Here on Opera when I edit and submit the changes dont show yet... have to refresh it again before it shows. Works on the SC forums so I guess its just a WaForum software problem.


@clementj
Anyway back to the problem.

Theres two ways:
- You can get the w/h via the .getWidth() or .getHeight() function. Please note that these 2 files will return the w/h of the object. This means that if you set the w/h manually in xml it will return this value instead of the auto w/h of the layer of you didnt specify anything. If the image change and you didnt change the w/h manually this also return the new image w/h. So can work very nice .
I used this back in the days where I was busy with Nullsoft Media Player 10.

- The other method and also the recommended one is that you get the value via a map. Here is an example of code:
PHP Code:
Map myMap = new Map;
myMap.loadMap("wasabi.list.background");
int myInt myMap.getWidth();
delete myMap
Just remember to delete the Map when your done! I didnt know this when I started using this method for Winamp-2006 and the memory usage will go up like mad on each read
The Map object also have other nice stuff (see std.mi)

ClassicPro© v2.01 : This plugin allows you to use cPro skins in Winamp. ClassicPro skins are all SUI skins and loads very quickly. ClassicPro skins is even easier to skin than Winamp Classic skins. A new layout have been added since version 2.
Download ClassicPro© ==== cPro Skins ==== ClassicPro© Homepage ==== SC Forums
pjn123 is offline   Reply With Quote
Old 23rd November 2008, 22:34   #5
Michgelsen
Major Dude
 
Michgelsen's Avatar
 
Join Date: Oct 2003
Location: Netherlands
Posts: 1,416
Quote:
Originally posted by pjn123
@Michgelsen - Here on Opera when I edit and submit the changes dont show yet... have to refresh it again before it shows. Works on the SC forums so I guess its just a WaForum software problem.
I use Opera too, but 'back in the days' when I visited these boards a lot there never were any problems.
Michgelsen is offline   Reply With Quote
Old 23rd November 2008, 22:59   #6
pjn123
Major Dude
 
pjn123's Avatar
 
Join Date: Jan 2006
Location: /\/¯¯¯¯¯\/\ , South-Africa
Posts: 1,030
Yes, here too... this started to happen sometime the last 2months I think

ClassicPro© v2.01 : This plugin allows you to use cPro skins in Winamp. ClassicPro skins are all SUI skins and loads very quickly. ClassicPro skins is even easier to skin than Winamp Classic skins. A new layout have been added since version 2.
Download ClassicPro© ==== cPro Skins ==== ClassicPro© Homepage ==== SC Forums
pjn123 is offline   Reply With Quote
Old 24th November 2008, 02:06   #7
clementj
Senior Member
 
Join Date: Oct 2006
Posts: 356
Ok, the getwidth() works, but with a strange problem.
It works for one file, but not for the other.
I have
userPictureW = 200; //at one point in the code
.............. later
userPictureW = userpicture.getwidth();
.... A subsequent debug statement shows the width to be 200 instead of the actual width. It looks like the second assignment to the variable is not working! But why????????????????

Incidentally getheight() works for the same file, but not getwidth()
clementj is offline   Reply With Quote
Old 24th November 2008, 02:52   #8
pjn123
Major Dude
 
pjn123's Avatar
 
Join Date: Jan 2006
Location: /\/¯¯¯¯¯\/\ , South-Africa
Posts: 1,030
The funtion work. There was a time where both getHeight & getWidth return the same value but it was fixed long tome ago.

Make sure that your element dont have a w="200".
If thats not it maybe post the code... probably just a typo somewhere then

ClassicPro© v2.01 : This plugin allows you to use cPro skins in Winamp. ClassicPro skins are all SUI skins and loads very quickly. ClassicPro skins is even easier to skin than Winamp Classic skins. A new layout have been added since version 2.
Download ClassicPro© ==== cPro Skins ==== ClassicPro© Homepage ==== SC Forums
pjn123 is offline   Reply With Quote
Old 24th November 2008, 06:05   #9
clementj
Senior Member
 
Join Date: Oct 2006
Posts: 356
There was a timing error. Now it all works.
getwidth() returns either the actual width or "w" if it is defined.

The call to getwidth must be done after the onscriptloaded(). So it must be done by a timer. The ontimer happened after onresize(), and the onresize was setting "w".

Thanks for the tips.
clementj is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Skinning and Design > Modern Skins

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump