XBMC Community Forum
Converting skins to 1920x1080 - Printable Version

+- XBMC Community Forum (http://forum.xbmc.org)
+-- Forum: Development (/forumdisplay.php?fid=32)
+--- Forum: Skin Development (/forumdisplay.php?fid=12)
+--- Thread: Converting skins to 1920x1080 (/showthread.php?tid=124314)

Pages: 1 2 3 4 5 6


Converting skins to 1920x1080 - phil65 - 2012-03-01 06:55

Any skilled coder here who can quickly write a program to convert 720p xmls to 1080? had a chat about that with someone from team blackbolt some time ago, but it never became reality.
all <posx> und <posy> tags would have to be multiplied by 1.5 and then rounded up, and if possible, the same for the animation tags, which are probably a bit more difficult to parse/modify.
I´m tryin it with perl myself atm, just didn´t get it till now.
thanks in advance

EDIT: wrote a program myself now, here it is:

https://github.com/phil65/xmlconvertgui/

Converts ALL skin coordinates/font sizes to their corresponding 1920x1080 values. you only have to adjust the addon.xml yourself.

Can also detect unused textures.


- Jezz_X - 2012-03-01 09:39

The question I got to ask is why ? xbmc automatically does what your trying to do anyway when you turn it to 1080p, so whats the point ?

Now making one from scratch in 1080p is a different thing alltogether and it more comes down to the images than the xmls


- BigNoid - 2012-03-01 12:21

One reason for doing this is if you already have 1080p textures, but a skin coded in 720p. For instance using border= on textures works good on native resolution of textures, but when you are coding 720p with 1080p textures that really screws that up.


- phil65 - 2012-03-06 03:53

i just created this in VB:

Code:
Sub Main()
        Try
            'Create the XmlDocument.
            Dim doc As New XmlDocument()
            doc.Load("C:\test_in.xml")

            'Change x Values
            Console.WriteLine("Changing posx values...")
            Dim elemList As XmlNodeList = doc.GetElementsByTagName("posx")
            Dim i As Integer
            For i = 0 To elemList.Count - 1
                Console.Write(elemList(i).InnerXml)
                Console.Write(" => ")
                elemList(i).InnerXml = Math.Round(elemList(i).InnerXml * 1.5)
                Console.WriteLine(elemList(i).InnerXml)
            Next i
            'Change y Values
            Console.WriteLine("Changing posy values...")
            Dim elemList2 As XmlNodeList = doc.GetElementsByTagName("posy")
            For i = 0 To elemList2.Count - 1
                Console.Write(elemList2(i).InnerXml)
                Console.Write(" => ")
                elemList2(i).InnerXml = Math.Round(elemList2(i).InnerXml * 1.5)
                Console.WriteLine(elemList2(i).InnerXml)
            Next i

            ' 2. Save the modified XML to a file in Unicode format.
            doc.PreserveWhitespace = True
            Dim wrtr As XmlTextWriter = New XmlTextWriter("C:\test_Out.xml", Encoding.Unicode)
            doc.WriteTo(wrtr)
            wrtr.Close()
            Console.WriteLine("C:\test_Out.xml is created")
            Console.ReadLine()

        Catch xmlex As XmlException                  ' Handle the Xml Exceptions here.
            Console.WriteLine("{0}", xmlex.Message)
        Catch ex As Exception                        ' Handle the generic Exceptions here.
            Console.WriteLine("{0}", ex.Message)
        End Try
    End Sub

can anyone help me to write the output file with the correct encoding?
is Unicode right? How can I choose ANSI?
when I convert an XML (taken from confluence) with that, all line breaks are removed....

EDIT: I think I got it Smile
here´s the code to convert the posx, posy, width and height values to 1080p. the animations have to be tweaked by hand, don´t know if i will get that running too.
Code:
Imports System.Xml
Imports System.Text
Imports System
Imports System.IO

Module Module1

    Sub Main()
        Try
            'Create the XmlDocument.
            Dim doc As New XmlDocument()
            doc.Load("C:\test_in.xml")

            'Change x Values
            Console.WriteLine("Changing posx values")
            Dim elemList As XmlNodeList = doc.GetElementsByTagName("posx")
            Dim i As Integer
            For i = 0 To elemList.Count - 1
                Console.Write(elemList(i).InnerXml)
                Console.Write(" => ")
                elemList(i).InnerXml = Math.Round(elemList(i).InnerXml * 1.5)
                Console.WriteLine(elemList(i).InnerXml)
            Next i
            'Change y Values
            Console.WriteLine("Changing posy values")
            Dim elemListposy As XmlNodeList = doc.GetElementsByTagName("posy")
            For i = 0 To elemListposy.Count - 1
                Console.Write(elemListposy(i).InnerXml)
                Console.Write(" => ")
                elemListposy(i).InnerXml = Math.Round(elemListposy(i).InnerXml * 1.5)
                Console.WriteLine(elemListposy(i).InnerXml)
            Next i
            'Change width Values
            Console.WriteLine("Changing width values")
            Dim elemListwidth As XmlNodeList = doc.GetElementsByTagName("width")
            For i = 0 To elemListwidth.Count - 1
                Console.Write(elemListwidth(i).InnerXml)
                Console.Write(" => ")
                elemListwidth(i).InnerXml = Math.Round(elemListwidth(i).InnerXml * 1.5)
                Console.WriteLine(elemListwidth(i).InnerXml)
            Next i
            'Change height Values
            Console.WriteLine("Changing height values")
            Dim elemListheight As XmlNodeList = doc.GetElementsByTagName("height")
            For i = 0 To elemListheight.Count - 1
                Console.Write(elemListheight(i).InnerXml)
                Console.Write(" => ")
                elemListheight(i).InnerXml = Math.Round(elemListheight(i).InnerXml * 1.5)
                Console.WriteLine(elemListheight(i).InnerXml)
            Next i
            'Change textwidth Values
            Console.WriteLine("Changing textwidth values")
            Dim elemListTextWidth As XmlNodeList = doc.GetElementsByTagName("textwidth")
            For i = 0 To elemListTextWidth.Count - 1
                Console.Write(elemListTextWidth(i).InnerXml)
                Console.Write(" => ")
                elemListTextWidth(i).InnerXml = Math.Round(elemListTextWidth(i).InnerXml * 1.5)
                Console.WriteLine(elemListTextWidth(i).InnerXml)
            Next i
            'Change textoffsetx Values
            Console.WriteLine("Changing textoffsetx values")
            Dim elemListTextoffsetx As XmlNodeList = doc.GetElementsByTagName("textoffsetx")
            For i = 0 To elemListTextoffsetx.Count - 1
                Console.Write(elemListTextoffsetx(i).InnerXml)
                Console.Write(" => ")
                elemListTextoffsetx(i).InnerXml = Math.Round(elemListTextoffsetx(i).InnerXml * 1.5)
                Console.WriteLine(elemListTextoffsetx(i).InnerXml)
            Next i
            'Change textoffsety Values
            Console.WriteLine("Changing textoffsety values")
            Dim elemListTextoffsety As XmlNodeList = doc.GetElementsByTagName("textoffsety")
            For i = 0 To elemListTextoffsety.Count - 1
                Console.Write(elemListTextoffsety(i).InnerXml)
                Console.Write(" => ")
                elemListTextoffsety(i).InnerXml = Math.Round(elemListTextoffsety(i).InnerXml * 1.5)
                Console.WriteLine(elemListTextoffsety(i).InnerXml)
            Next i
            'Change radioposx Values
            Console.WriteLine("Changing radioposx values")
            Dim elemListradioposx As XmlNodeList = doc.GetElementsByTagName("radioposx")
            For i = 0 To elemListradioposx.Count - 1
                Console.Write(elemListradioposx(i).InnerXml)
                Console.Write(" => ")
                elemListradioposx(i).InnerXml = Math.Round(elemListradioposx(i).InnerXml * 1.5)
                Console.WriteLine(elemListradioposx(i).InnerXml)
            Next i
            'Change radioposy Values
            Console.WriteLine("Changing radioposy values")
            Dim elemListradioposy As XmlNodeList = doc.GetElementsByTagName("radioposy")
            For i = 0 To elemListradioposy.Count - 1
                Console.Write(elemListradioposy(i).InnerXml)
                Console.Write(" => ")
                elemListradioposy(i).InnerXml = Math.Round(elemListradioposy(i).InnerXml * 1.5)
                Console.WriteLine(elemListradioposy(i).InnerXml)
            Next i
            'Change radiowidth Values
            Console.WriteLine("Changing radiowidth values")
            Dim elemListradiowidth As XmlNodeList = doc.GetElementsByTagName("radiowidth")
            For i = 0 To elemListradiowidth.Count - 1
                Console.Write(elemListradiowidth(i).InnerXml)
                Console.Write(" => ")
                elemListradiowidth(i).InnerXml = Math.Round(elemListradiowidth(i).InnerXml * 1.5)
                Console.WriteLine(elemListradiowidth(i).InnerXml)
            Next i
            'Change radioheight Values
            Console.WriteLine("Changing radioheight values")
            Dim elemListradioheight As XmlNodeList = doc.GetElementsByTagName("radioheight")
            For i = 0 To elemListradioheight.Count - 1
                Console.Write(elemListradioheight(i).InnerXml)
                Console.Write(" => ")
                elemListradioheight(i).InnerXml = Math.Round(elemListradioheight(i).InnerXml * 1.5)
                Console.WriteLine(elemListradioheight(i).InnerXml)
            Next i
            ' 2. Save the modified XML to a file in Unicode format.
            doc.PreserveWhitespace = True
            Dim wrtr As XmlTextWriter = New XmlTextWriter("C:\test_Out.xml", Encoding.Unicode)
            wrtr.Formatting = Formatting.Indented
            doc.WriteTo(wrtr)
            wrtr.Close()
            Console.WriteLine("C:\test_Out.xml is created")
            Console.ReadLine()

        Catch xmlex As XmlException                  ' Handle the Xml Exceptions here.
            Console.WriteLine("{0}", xmlex.Message)
        Catch ex As Exception                        ' Handle the generic Exceptions here.
            Console.WriteLine("{0}", ex.Message)
        End Try
    End Sub

End Module

EDIT: added some more elements:
it now converts posx,posy,width,height,textwidth,textoffsetx,textoffsety,radioposx,radioposy,rad​iowidth,radioheight.
can post an exe if someone wants it.


- ZombieRobot - 2012-03-06 07:18

Phil your the man i dont know how long i have needed this exact thing


- phil65 - 2012-03-06 08:03

ZombieRobot Wrote:Phil your the man i dont know how long i have needed this exact thing

no problem. let me know if it works for you.


- jmarshall - 2012-03-06 08:15

Nice work. Some notes to improve your program (feel free to ignore!)

1. Put the 1.5 in a (constant) variable, so you can more easily change it later should a different transformation be required.

2. Put the tag names into an array at the top, and cycle through that array rather than c&p the code multiple times. Alternatively, make the bit you've c&p'd a function that takes in the info it needs to do the conversion and then just call that function with each different tag you need to convert. Much faster to change then, and it makes sure all the code blocks are identical.

Cheers,
Jonathan


- phil65 - 2012-03-06 09:03

jmarshall Wrote:Nice work. Some notes to improve your program (feel free to ignore!)

1. Put the 1.5 in a (constant) variable, so you can more easily change it later should a different transformation be required.

2. Put the tag names into an array at the top, and cycle through that array rather than c&p the code multiple times. Alternatively, make the bit you've c&p'd a function that takes in the info it needs to do the conversion and then just call that function with each different tag you need to convert. Much faster to change then, and it makes sure all the code blocks are identical.

Cheers,
Jonathan

thx for feedback.
I will try to set up a small gui to make things easier to use and optimize the code as you said.
I just don´t succeed with transforming the animation attributes "start" and "end" at the moment because they can have different amount of coordinates. any help is greatly appreciated.


- eumel - 2012-03-06 09:57

phil65 Wrote:Any skilled coder here who can quickly write a program to convert 720p xmls to 1080? had a chat about that with someone from team blackbolt some time ago, but it never became reality.
It became reality, you have to ask Equinox, he is the man wrote one script.


- phil65 - 2012-03-06 10:34

did this tool convert the animation tags, too?

EDIT: optimized code and created a gui. i can upload it if someone wants it.

[Image: skinconvert.jpg]


- fmronan - 2012-03-06 14:04

I'm intresting for my skin


- phil65 - 2012-03-06 14:12

one question to jmarshall before releasing: which encoding should i set: unicode or ASCII?
got batch converting implemented now Smile i´m starting to like Visual Basic Big Grin


- spiff - 2012-03-06 14:17

an alternative, and imo better solution than a platform dependent visual basic application, would be to use a xslt transformation. don't have time to give an example right now but google around..


- Hitcher - 2012-03-06 14:17

ANSI or UTF-8?


- phil65 - 2012-03-06 15:28

spiff Wrote:an alternative, and imo better solution than a platform dependent visual basic application, would be to use a xslt transformation. don't have time to give an example right now but google around..

I agree that multiplatform would be nicer, but after googling around I decided that VB would be the easiest for me. (I´m no programmer)
and since this is a one-time-use tool, i hope it´s ok to release it windows-only.