adventuregamestudio / ags

AGS editor and engine source code
Other
708 stars 159 forks source link

Support importing 4-bit bitmaps as 8-bit (for masks and sprites) #2419

Closed ivan-mogilko closed 6 months ago

ivan-mogilko commented 6 months ago

Fixes #2416

Implemented a conversion from imported 4-bit bitmaps into 8-bit ones supported by the Editor & Engine.

There were 2 potential approaches here, one is to convert on C# side, another in the native C++ side. I chose to do this in native, and have a helper function in Common lib, to make this potentially usable in the engine. For example, this may be used when loading an image from file.

ericoporto commented 6 months ago

I don't know if useful or not, but I think the engine does loads 4-bit bitmap already. I remember to have written it here

https://github.com/adventuregamestudio/ags/blob/01b73a09c0f806260d9ef5a6ef6cf076afa6c907/Common/gfx/bitmap.cpp#L344

ivan-mogilko commented 6 months ago

Ah, this reading function unpacks 4-bit to 8-bit on read. Well then, this means that the new conversion function may not be necessary for loading bitmaps at runtime. It's only needed if an unpacked data is read, and needs to be converted. But the loading function cannot be used in this particular case, as bitmap already comes from the managed side.

EDIT: On another hand, something I wanted to suggest for the future is to not read data directly into Bitmap object (or write directly from Bitmap object), but using a raw pixel array. This would make image loading and saving functions independent from Bitmap class. That is something for a separate task though.