Expose ControlImage AspectRatio
#1
anybody feel up to exposing this to us python scripters. i have looked into it but it appears to be over me at the moment. i would greatly appreciate it.
Reply
#2
hi
i made this function to resize a picture whatever orientation it is (landscape or portrait)
get_size_pic(picfile,maxw=400,maxh=400)
where :
- picfile is the path to the picture file
- maxw is an int for the maximum width you want (default=400)
- maxh is an int for the maximum height you want (default=400)
you need the pil library (python image library) installed (import image)
it is usefull if you need a pic to fit exactly in an area whatever orientation is
this function returns the width and height need to respect orientation of the picture and to fit properly in the area you want

Quote:import image
def get_size_pic(self,picfile,maxw=400,maxh=400):
#open the pic file as an object using pil
im = image.open(picfile)
#get the width and height of the pic file object
width,height=im.size
#some manipulations to get the correct ratio
#ratio of the widths
qw=float(width)/float(maxw)
#ratio of th heights
qh=float(height)/float(maxh)
#ratio to keep is the biggest
coeff=max(qw,qh)
#calculate the width and height of the pic to shox properly
wpic=int(width/coeff)
hpic=int(height/coeff)

return wpic,hpic
Reply
#3
thanks for your reply... that code is useful.. i use a similar function now... the problem is when someone uses a resolution outside of what i use it will strecth the picture. i have my script to set coordinates for ntsc.. but when someone uses pal or and hd res it stretches the image. now if someone uses ntsc widescreen it stretches it too but that is expected. i was hoping to get access to the aspectratio of the control image so this wouldn't be a problem. unfortunately i'm not quite proficient enough inside the xbmc code to figure out how to expose it.
Reply
#4
i think you already use the :
self.setcoordinateresolution(x)
this modify positions and width/height of the gui to fit whatever resolution the user screen is.
but as for pictures, they still stretched...
you'll have to size the picture not by using just the width and height, but you'll better add a parameter which calculate the pixel ratio of the screen to adapt the picture width and height.
Reply
#5
thanks for the suggestion... i guess i should have explained a bit more in my original request. it is possible to work around the resolution and manually determine the size for each image. i guess i was thinking that xbmc already has the ability to do this without having to manually do it.... so why redo the work if it this could be exposed to python. i just don't know enough about the xbmc code to dive in and expose this ability i found out.
Reply
#6
only the :
self.setcoordinateresolution(x)
stuff is actually exposed to python
Reply
#7
- 02-05-2006 fixed: image controls from python couldn't be set to preserve aspect ratio.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#8
nice. Smile
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#9
thanks so much for working on this. i hope it wasn't too much extra work. you wouldn't happen to remember the syntax off the top of your head would you?

thanks again.
Reply
#10
controlimage(int x, int y, int width, int height[, filename, colorkey, aspectratio])
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#11
thanks!
Reply
#12
i played with this a little and couldn't get it to do anything. i may not understand how to use it.

i placed three images who's size is 180 x 180 on the screen at 180w x 100h. i used 0,1,2 for the aspect ratio(i think that's correct, it does want an integer). all three images appeared stretched.

is the correct entry for aspect ratio an integer (0,1,2)?

am i misunderstanding what this does?
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#13
i just got the code from sourceforge and it looks to me like keep=0, scale=1, stretch=2. but i havent gotten a chance to actually test it yet so i can't confirm that it works.
Reply
#14
i didn't actually test it, but i don't really see what could be wrong with it (it just calls setaspectratio() after creating the image).

do me up a script and i'll make sure it works Wink

cheers,
jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#15
i used rapidshare.

controlimage test
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply

Logout Mark Read Team Forum Stats Members Help
Expose ControlImage AspectRatio0