benfry / processing4

Processing 4.x releases for Java 17
https://processing.org
Other
1.35k stars 237 forks source link

.tga PImage flips y axis after save() and load() #827

Open Sebastian5 opened 8 months ago

Sebastian5 commented 8 months ago

Description

ONLY when pixels are saved ( PImage.save() ) as .tga and loaded again ( loadImage() ) they are fliped on the y axis.

Expected Behavior

That the image doesnt flip. The demo code should show the red dot in the top left corner, not the bottom left.

Current Behavior

It is unclear whether the PImage.save() or loadImage() function is the root of the bug.

The Problem does NOT occur when: If you save and image as .tga and open it with Paint.net: looks correct in Paint.net, not flipped If you load an .tga created from Paint.net: looks correct in Processing, not flipped

But for .tga images that were PImage.save() and loadImage(). It flipps the pixels. It is very strange

Steps to Reproduce

PImage img1 = createImage(5, 5, RGB); img1.pixels[0] = color(255,0,0); // left top corner must be red img1.updatePixels(); img1.save("img.tga");

PImage img2 = loadImage("img.tga"); // comment out after using Paint.net to re-save image non corrupt image(img2,0,0, width, height);

Your Environment

Possible Causes / Solutions

Maybe there is file desciptor flag to flip an image in the y axis.