0

I need to have an image at a different size as it is too small because I made it a pixel art, I didn't use an image editor to resize, as it would make it blurry. I need to resize it to fit the window.

My code is:

PImage logo;
int logoX = 250;
int logoY = 250;

void setup()
{
  //Canvas
  size(500, 610);

  //Background
  background(143, 132, 205);

  //Create the logo
  logo = loadImage("Tetris Java.png");
  image(logo, logoX, logoY);
}

I don't need exact dimensions, but they would be helpful.

matt
  • 10,892
  • 3
  • 22
  • 34
Deco
  • 3
  • 1
  • Hi Deco, to make easier for experts to find your questions please add the correct tags for your question. Java has a lot of image processing libraries. Best of luck – Aboodz Dec 21 '19 at 10:32
  • [Java - resize image without losing quality](https://stackoverflow.com/questions/24745147/java-resize-image-without-losing-quality/36367652) – Abra Dec 21 '19 at 10:36
  • Abra this doesn't help, and also Aboodz Idk what tags to use. – Deco Dec 21 '19 at 10:42
  • Deco you have a lot of methods here that we don't know what they're for. For example "loadImage" is that from a library, or is that a method that you wrote? Also, do you currently display the image? What is wrong with it if so. – matt Dec 21 '19 at 10:51
  • your question is answered in this post: https://stackoverflow.com/a/5896284/3021180 – Ali Gol Gol Dec 21 '19 at 11:07

1 Answers1

0

Lets assume you're using processing since it has a PImage. If you want a resized version of your image.

PImage logoScaled = new PImage( logo.getImage().getScaledInstance(newWidth, newHeight, Image.SCALE_DEFAULT) );

That should give you a scaled version. Also when you call image(logo, logoX, logoY), there is a 5 argument version where you can specifiy the dimensions.

image(logo, logoX, logoY, desiredWidth, desiredHeight);

These are two different ways. If you are using processing then you should add the tag, and you might get better help.

matt
  • 10,892
  • 3
  • 22
  • 34