Skip to content

Comments

Maniacs Patch - SetPicturePixel Command + GetPictureInfo Update#3501

Open
jetrotal wants to merge 17 commits intoEasyRPG:masterfrom
EasyRPG-NewFeatures:maniacs/drawPictureCommand
Open

Maniacs Patch - SetPicturePixel Command + GetPictureInfo Update#3501
jetrotal wants to merge 17 commits intoEasyRPG:masterfrom
EasyRPG-NewFeatures:maniacs/drawPictureCommand

Conversation

@jetrotal
Copy link
Contributor

@jetrotal jetrotal commented Dec 7, 2025

Another one that must come in pairs:

SetPicturePixel Command

Implements the CommandManiacSetPicturePixel function to allow direct pixel manipulation of game pictures via event commands. Handles bitmap uniqueness, format conversion, and window picture detachment to ensure safe editing. Updates command dispatch logic and header declaration.


Update - GetPictureInfo (pixel data extraction)

Adds support for extracting raw pixel data from pictures, including window-type pictures with forced refresh. Optimizes out-of-bounds handling to preserve variable values and ensures only 32-bit bitmaps are processed. Existing logic for info types 0, 1, and 2 remains unchanged.


TODO:

  • Save persistence
  • Few Quirks that I could not figure out, e.g.:
    I assumed some opacity changes between maniacs and easyRPG were due to out of bounds color picking. But I was wrong, someone smarter than me could help me with that.

Map0003.zip

Implements the CommandManiacSaveImage function, allowing saving of screen or picture images to disk
…d fallback on loading image

Better handle opaque and effects flags

Added support for cropping spritesheet frames

Updated FileFinder to use open_generic_with_fallback for image loading.
@jetrotal
Copy link
Contributor Author

jetrotal commented Dec 9, 2025

Also supporting game Info pixels, test map:
Map0003.zip

Added support for the 'Pixel Info' option in the CommandManiacGetGameInfo function. This captures a screen region, extracts pixel data as packed AARRGGBB values, and stores them in game variables, matching Maniacs behavior. Out-of-bounds pixels are skipped, and alpha is forced to opaque.
Implements the CommandManiacSetPicturePixel function to allow direct pixel manipulation of game pictures via event commands. Handles bitmap uniqueness, format conversion, and window picture detachment to ensure safe editing. Updates command dispatch logic and header declaration.
@jetrotal jetrotal force-pushed the maniacs/drawPictureCommand branch from 4aeebe0 to 1f6990f Compare December 10, 2025 02:17
@Ghabry
Copy link
Member

Ghabry commented Jan 8, 2026

Imo that's a good base but (while testing) I will try to optimize this for max performance.

I read discussions in various RPG Maker chatrooms about the performance of these pixel operations in Maniacs so lets make this fast.


You cannot know this but the function uint32_to_rgba performs surprisingly bad (during benchmarking) and I don't really know why as in the end it does the same as a bit shift (I have an improved version locally and it still runs worse for reasons unknown)

Should be faster to convert the entire relevant picture area in one go via Pixman to the format the Var Array wants and then memcpy it from/to the Variable array. But will also have to bench this :).

Ghabry and others added 9 commits February 11, 2026 18:53
…d_file_with_fallback

Removed the find file function as was unused
Now matches exactly what Maniacs is saving
Adds support for extracting raw pixel data from pictures, including window-type pictures with forced refresh. Optimizes out-of-bounds handling to preserve variable values and ensures only 32-bit bitmaps are processed. Existing logic for info types 0, 1, and 2 remains unchanged.
@Ghabry
Copy link
Member

Ghabry commented Feb 21, 2026

There is one edge-case I probably cannot fix: Reading from transparent pixel.

E.g. Actor1 has a green background which becomes transparent.

When reading now such a transparent pixel:

  • Maniac: The value read is this green color
  • EasyRPG: The value is (0,0,0,0) because we use premultiplied alpha

Premultiplied alpha is pretty standard when doing graphic processing so most libraries use it (including pixman).

Not touching big endian as this would require further testing.

Has the same base performance as ABGR so is okay to use.

Makes Masked Blit much faster (see EasyRPG#3497), Pixman fast path probably?
Also is the format used by Maniacs so the pixel operations are faster
Most compatible with what Maniacs is doing
At least we can load Maniacs images but Maniacs shows nothing
@Ghabry Ghabry force-pushed the maniacs/drawPictureCommand branch from 1f6990f to 55307fd Compare February 21, 2026 18:19
@Ghabry Ghabry added this to the 0.8.2 milestone Feb 21, 2026
@Ghabry
Copy link
Member

Ghabry commented Feb 21, 2026

rebased this on #3498 because some code is shared.

Okay this feature is actually pretty cool :)

@jetrotal once the build is finished could you test this a bit? (or better ask around if anybody knows games that use all this pixel reading/writing stuff so we can find bugs in the implementation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants