Hello! I was trying to set up the basis for a game engine and wanted to load a sprite sheet that would then display only parts of itself at a time. Did some research and found this which looked to have exactly what I wanted! I set up a basic test that would size an image to your screen with appropriate margins, along with setting some variables for scaling other aspects.
Here is that code:
PImage test;
PImage player;
double scale;
double screenWidth;
int xOffset;
void setup() {
fullScreen();
test = loadImage("SILVER TORIZO BOSS ROOM.2022-10-11.03-01-54.png");
scale = (displayHeight / test.height);
screenWidth = (int) (scale * test.width);
xOffset = (int) ((displayWidth - screenWidth) / 2);
}
void draw() {
background(100);
image(test, xOffset, 0, (int) screenWidth, displayHeight);
fill(0);
rect(0, 0, xOffset, displayHeight);
rect((int) (xOffset + screenWidth), 0, xOffset, displayHeight);
}
Wonderful! Now, I added the code to zoom in on part of this image to check to see if I had a handle on how to do so. So the
image(test, xOffset, 0, (int) screenWidth, displayHeight);
became
image(test, xOffset, 0, (int) screenWidth, displayHeight , 0, 48, 16, 16);
Which gives this
Doubling the Y fixes the image to show just the block, but it’s still flipped as well as very blurry. (I’m sure the blurring isn’t the image itself, the pixels are entirely crisp when I zoom in using paint)
So, I’m kinda at a loss here. There seems to be some mysterious method described by “gordancsa” that is mentioned in the other forum post I linked, but the link to said method throws a page not found. Is there something I’m doing wrong? Is this an issue with processing itself that I can’t fix? Does the mythical gordancsa method exist? Any help is appreciated, but either way thanks for reading and have a nice day