Problems with proper scaling of BufferedImage to a Quad

Hi,



I currently have problems with the proper scaling of a generated Java2D BufferedImage to a JME Quad. I need this for a full screen (full size of the JMECanvas) menu with text. Unfortunately the text doesn't look proper (frayed). When I just save the BufferedImage to a PNG file, the text looks proper. Here is the code I use for adding the BufferedImage to the Quad:


// preparing texture
TextureState ts = display.getRenderer().createTextureState();
Texture t = TextureManager.loadTexture(bufferedImg, Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR, 1, true);
ts.setTexture(t);
       
int w = bufferedImg.getWidth();
int h = bufferedImg.getHeight();
Quad q = new Quad("shoppinglist", w, h);
       
// putting the whole image on the JME Quad
q.setLocalTranslation(gameView.getCanvasWidth() / 2, gameView.getCanvasHeight() / 2, 0);
q.setRenderState(ts);
q.setRenderQueueMode(Renderer.QUEUE_ORTHO);
rootNode.attachChild(q);



Is it possible that it has something to do with wrong scaling of the BufferedImage to the Quad?

Any help would be much appreciated.

Thanks,

Michael

Perhaps it has to do with image compression.

Yeah. might be automatic compression, can you post up the pic to show what you mean by "frayed"? 

Also, if you are showing the quad at a 1:1 ratio, you can disable your minification and magnification filters to save some texture memory.

Hi,



Thank you very much for your replies. Finally I found out that the BufferedImage didn't have a size of power of two. After I did the following changes the text was very clear and sharp:


int imageWidth = FastMath.nearestPowerOfTwo(canvasWidth);
int imageHeight = FastMath.nearestPowerOfTwo(canvasHeigth);
       
BufferedImage bi = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);



@Renanse: Could you please explain me what you mean with "disabling the minification and magnification filters"? Are these the parameters used for TextureManager.loadTexture()? Currently I use the following for adding the buffered img to the quad (full size of canvas):

Texture t = TextureManager.loadTexture(bi, Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR, 1, true);



Thanks,

Michael

Yeah, so you could instead use MM_NEAREST, FM_NEAREST