[Nifty1.3] NiftyImageMode deprecated ? ( Solved )

I was finally able to update to a nighty build version of the JME ( I was still on the one from 2011-03-17 )

And here is the bad surprise : None of my CutomImageButton are displayed. It seems like there is a problem with the way I declare the overlay effect.

So I tried to find where I change my images, and I find this warning :

The type NiftyImageMode is deprecated.

I have checked the repository but I haven't found a similar class that may replace it.
How do I change those lines :
[java]
NiftyImage niftyImage = nifty.getRenderEngine().createImage( img, false );
niftyImage.setImageMode( NiftyImageMode.valueOf("resize:15,2,15,9,15,2,15,2,15,2,15,9") );
[/java]
Thanks :)

Well, first of all the code you’ve posted is still being supported and should still work as is (despite the deprecation of the class). There is probably something else wrong!?



About the deprecation:



We’ve applied a user contributed patch to Nifty that changed the way the Nifty image modes work internally. The patch changed the way the image modes are rendered inside of Nifty to allow even more image modes to be supported. If you are interessted in the new additional image modes please take a look at the de.lessvoid.nifty.render.image.ImageModeFactory class for details ( The NiftyImageMode has been split into two: a way to get the source image and a way to render that source image. This allows additional nifty stuff :wink: )



However this change does not (!) affect any of the XML imagemodes as well as the usage of the imagemodes from Java (your code should still work) and in fact it was not necessary to change any of the Nifty examples for this at all.



You can still use the deprecated class because this API won’t change in 1.3 anymore.



The solution without the deprecated class looks currently like this:



[java]NiftyImage niftyImage = nifty.getRenderEngine().createImage( img, false );

String areaProviderProperty = new ImageModeHelper().getAreaProviderProperty(“resize:15,2,15,9,15,2,15,2,15,2,15,9”);

String renderStrategyProperty = new ImageModeHelper().getRenderStrategyProperty(“resize:15,2,15,9,15,2,15,2,15,2,15,9”);

niftyImage.setImageMode(ImageModeFactory.getSharedInstance().createImageMode(areaProviderProperty, renderStrategyProperty));[/java]



Which I am not too happy with but which works ok for the moment.

Ok, thanks :slight_smile:



I works fine with the new method. Problem solved !