# resize images in libgdx

I know how to set Image width and height using pixel coords. Is there a way to set relative coords? I want to deal with multiple screens.

For example i have 1920x1080 screen size. And i have relative coords width (-100,100) and height = 200*1080/1920=112.5, height(-56.25, 56.25)

Can i use this relative coords to set width and height? and how to do it? Is there any best practices to handle different screens ratio, handle orientation change correctly?

here is how i'm using it in my app:

create()

    public void create() {
stage = new Stage();
Gdx.input.setInputProcessor(stage);

camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.setToOrtho(true, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.update();

Skin skinBackground = new Skin();
background=new Image(skinBackground,"background");

if(background!=null) {
background.setWidth(width);
background.setHeight(height);
}
}


render

public void render() {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
Gdx.gl.glClearColor(255/255f, 255/255f, 255/255f, 1);
stage.getBatch().setProjectionMatrix(camera.combined);
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
}

• I am a little confused. Are you asking how to make the image width and height the same in all screen sizes? – JDSweetBeat Sep 18 '15 at 15:05
• Yes, it's what I want. And also to support all screen orientation – Jenya Kirmiza Sep 29 '15 at 21:37