processing / processing/processing4

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

Open
#827 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug core
Dominant language
Java
Stars
494
Forks
183
Avg merge
4h 39m
Merged PRs (30d)
3

Description

Created by: Sebastian5

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

  • Processing version: 4.3
  • Operating System and OS version: Windows 10 Pro 22H2
  • Other information: AMD GPU Andrenail 23.12.1, Intel CPU

Possible Causes / Solutions

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the PImage.save() and loadImage() paths involved in .tga handling, then run the supplied 5×5 reproduction on Processing 4.3. Trace whether saving or loading changes the vertical pixel order; done means the red pixel remains in the top-left after saving and loading the TGA.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.