Nifty Resizing an image in XML(need help)

As I didn’t tag this as a support topic, I noticed that I got no replies though all the other posts got really fast replies. So here I post it again. Please help me

Hey there, I have the following problem:
I want to resize a .png image to the panel size. So my Idea was:

<panel id=”tutorialbutton” childLayout=”center” height=”25%” width=”95%”
align=”center” valign=”bottom” backgroundColor=”#08a3″>
<image filename=”Interface/button.png”
ImageMode=”resize:50,20,50,48,50,20,50,2,50,20,50,48″
width=”100%” height=”100%”/>
<text text=”tutorial” font=”Interface/Fonts/SegoeUI.fnt”
width=”100%” height=”100%”>
</text>
</panel>

I thought the ImageMode=”resize:…” ensures that it is resized correctly (i.e. for buttons don’t resize the fancy corners but only the middle part, as in the Nifty GUI manual page 39)
But instead it forces my image into the panel, distorting it, ignoring my ImageMode-attribute.

I really think that there must be another way to resize this .png so that the xml-file does the resizing correctly, but I can’t find the commands.
Could you help me please?

Thanks :slight_smile:

Sincerely, Zariem

Hello,
Could you post a screenshot about your button and your gui? maybe the image mode parameters are incorect… or your Interface/button.png is bigger than the actual panel size.


I hope that works… These Pictures show the button once in its normal size and once stretched.

Well that didn’t work. I’ll try again with these links…

https://onedrive.live.com/redir?resid=DCC6C7FE1CADBAC4!113&authkey=!AHtFCjSnB2ZyNOc&v=3&ithint=photo%2CJPG

https://onedrive.live.com/redir?resid=DCC6C7FE1CADBAC4!114&authkey=!AA4-wQZdzNkSi4w&v=3&ithint=photo%2CJPG

Also, the panel is the light blue box around it…

Thanks for sharing! To a first glance as you said seems that the image mode is ignored, is nifty complaining about something? could yuo share also only the image of the button ? I would make some tests!.

About images you have to provide the direct link to the image like this :

Umm, the only complaint I see when running the program is that I don’t have a ScreenController(), but it’s using the default ScreenController() instead.
I’m pretty new to jme, so I don’t really know whether this influences my xml-file, but I actually don’t think so.

And really, I have no clue on how to upload pictures here in the forum… So I’ll just post another link…
http://sta.sh/01iqkanjvgtb

Hello it seems that I can’t understand why it’s not working… try with this xml :
[xml]
<?xml version=“1.0” encoding=“UTF-8” standalone=“yes”?>
<nifty xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xmlns=“http://nifty-gui.lessvoid.com/nifty-gui” xsi:schemaLocation=“https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd https://raw.githubusercontent.com/void256/nifty-gui/1.4/nifty-core/src/main/resources/nifty.xsd”>
<useControls filename=“nifty-default-controls.xml”/>
<useStyles filename=“nifty-default-styles.xml”/>
<screen id=“GScreen0” controller=“mygame.Main”>
<layer id=“GLayer0” childLayout=“center”>
<panel id=“GPanel0” height=“30%” backgroundColor="#055" width=“50%” childLayout=“center”>
<image id=“GImage1” height=“100%” width=“100%” filename=“Interface/button.png” childLayout=“center” y=“51” imageMode=“resize:50,20,50,48,50,20,50,2,50,20,50,48” x=“139”>
<control name=“label” id=“GLabel0” text=“Tutorial” height=“50px” color="#000" font=“aurulent-sans-16.fnt” width=“100px”/>
</image>
</panel>
</layer>
</screen>
</nifty>
[/xml]
It was generated using the new desing view and there it works as expected . I’ve also set up a little jme project and it works also there.

Thanks for your help.
:slight_smile:

I’m sorry, but I copied the code snipped you gave me and the problem still doesn’t resolve ._.

The control’s text doesnt even appear on my distorted button anymore :confused:

This is strange… I can’t test again now but when I made it , all works fine both in visual editor and in a real game… I don’t know maybe a complete log of your application would help. Also if you are doing something fancy in the render thread it could influence the nifty render process. Could some other test my xml to see if it works as expected ? I really hope we can find why this isn’t working… !

Okay, wait, I now did an exact copy of your code and it worked fine. This is so weird :o
I must have done something wrong in my own code…

btw: the control’s text didn’t appear because I forgot adding the <useControls … /> line.

I’ll try figuring out what I did wrong :confused:

Thanks for all your effort :slight_smile:

Ah okay, I could definitely shoot myself in the head right now XD
I found my error while typing my entire xml into this post… i wrote ImageMode=“resize…” instead of imageMode=“resize…”
And as xml is case sensitive, It just ignored the whole ImageMode-attribute…
Of course there was no warning or something. No compiler was designed to tell me that I had written something it didn’t understand…

rrraaa! I hate these small errors XD

Thank you for your support.

Glad to hear that :smiley: ,

rrraaa! I hate these small errors XD

hahah , that’s why I built nifty-editor :slight_smile: . There is a lot more to do but the goal is, indeed, to avoid this little issues. :slight_smile:

1 Like
@relucri said: hahah , that's why I built nifty-editor :) . There is a lot more to do but the goal is, indeed, to avoid this little issues. ^_^

Oh wow, just watched the youtube video :smiley:
That program looks pretty sexy!
I’ll definitely check it out when I have a bit more time :slight_smile: