Ancurio / mkxp

Free Software implementation of the Ruby Game Scripting System (RGSS)
GNU General Public License v2.0
524 stars 137 forks source link

Extend RGSS: Saving bitmap to png files? #146

Closed BakaBBQ closed 8 years ago

BakaBBQ commented 8 years ago

That would make taking screenshots a lot more easier. I deem that quite a portion of Rpg Maker games use some kind of Win32API implementation of saving bitmap to png files to get "clean" screenshots. Adding this extension would make this Win32API hack non-necessary.

I am a bit in doubt in whether to add this (because this is more of just a convenience), and chunkypng can always be used. Just that I feel a lot of game engines have this and it would be great to have this in mkxp.

Ancurio commented 8 years ago

Most scripts I have seen so far read out the pixels one by one using #get_pixel, and then use the Zlib module to write them out as png. Can you show me a game using Win32API to create pngs?

BakaBBQ commented 8 years ago

@Ancurio I recall a lot of Chinese Rpg Maker games using either of the following two methods:

Call Win32API to take screenshot of the game window

Example (Japanese): http://cacaosoft.webcrow.jp/script/rgss3/file/save_bitmap.txt

see line 301, def self.save_screen(fn, type)

Call Win32API RtlMoveMemory to Avoid #get_pixel

Examples:

I could think of some games that depend on these scripts, yet my knowledge of Rpg Maker games are limited to the Chinese ones (and will not be very helpful to check out). The scripts listed above should be sufficient to prove that quite some games (both Chinese and Japanese) depend on Win32API for screenshots. Cacaosoft has existed for quite some time as quite a resourceful website.

Interesting enough is that all the screenshot scripts I have read depend on Win32API. I guess I entirely overlooked the possibility using plain RGSS to generate pngs (because I have almost no knowledge in the png format itself).

With that said, I find this feature of saving png from bitmaps maybe just an convenience because it is nothing like reading mouse input which cannot be achieved any way other than Win32API. I have no further interest in this feature now.

Ancurio commented 8 years ago

Ok, but the biggest reason Win32API is required by those scripts is to create a bitmap from the screen contents in the first place (for XP); if I wrote an RGSS extension to save bitmaps to pngs, you still wouldn't be able to take screenshots in XP mode, right? So you also need a way to access #snap_to_bitmap in XP mode for this to be useful. It's not really a big deal to do that.

I have no further interest in this feature now.

So you're not trying to port a game at the moment?

Ancurio commented 8 years ago

I guess I entirely overlooked the possibility using plain RGSS to generate pngs (because I have almost no knowledge in the png format itself).

The second link you posted does this.

BakaBBQ commented 8 years ago

I guess my mind is quite off at the moment: I will try to explain myself more clearly since the discussion has grown quite blurry.

As for whether these scripts exist just to replicate #snap_to_bitmap. In RMXP the answer is probably yes because #snap_to_bitmap is nonexistent. Yet in RGSS3 (the one I am most familiar with) these Win32API calls are mostly for quickly encoding bitmap into pngs. Also I think the reason people in RGSS2 (and as I recall probably in RGSS3) invoke Win32API calls to directly screenshot the game into pngs is because there is a lack of direct way to convert the #snap_to_bitmap result into png.

So you're not trying to port a game at the moment?

I am currently using the RGSS3 engine to write a game on my Mac using mkxp. I was trying to take screenshots until I realized all the screenshot scripts I found are reliant on Win32API calls.

Therefore I am not trying to port a game: just thought that this feature was common enough and currently implementations proved quite hacky. (I was unaware of the pure-RGSS approach until I read your first reply).

Regarding my second link, it was a mistake by me since I did not really go through the script and see what it did.

The reason I said I did not have any further interest was that I realized pure-RGSS implementations actually exist and are quite usable and pervasive. Thus it was probably out of mkxp's scope to implement this feature. Even if I were to port a game I can switch the Win32API version to a pure-RGSS version. Thus this is a trivial problem that can be solved by porters easily.

I feel kind of upset since if I were to investigate into the issue further, this issue would probably be nonexistent. I really thank you for the time into this somewhat messy issue.