Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regarding the issue of exporting boyfriend deathScreen images as PNG files #556

Open
VapireMox opened this issue Feb 19, 2025 · 1 comment

Comments

@VapireMox
Copy link

Well

  • Previously, I had an idea to record the images of death in FNF and export them as PNG files
  • To implement this idea, I went through countless haxeflixel and openfl source codes, and finally wrote the following code using hscript
import openfl.display.BitmapData;
import openfl.display.PNGEncoderOptions;
import openfl.geom.Rectangle;
import openfl.geom.Matrix;
import sys.io.File;
import sys.FileSystem;

function onSongStart() {
	//death
	health = 0;
}

function onGameOver(event) {
	screenShot([camGame, camHUD], "DeathScreen");
}

function screenShot(sb:Array<FlxCamera>, path:String) {
	//for draw and record camera screen
	var screen:BitmapData = new BitmapData(FlxG.width, FlxG.height, true, 0x00000000);
	
	if(FlxG.renderBlit) return;
	
	//you know
	var prevMatrix:Matrix = new Matrix();
	prevMatrix.scale(1 / Main.scaleMode.scale.x, 1 / Main.scaleMode.scale.y);
	for(sm in sb) {
		screen.draw(sm._scrollRect, prevMatrix);
	}
	
	if(!FileSystem.exists(path))
		FileSystem.createDirectory(path);
	
	var screenBytes:Dynamic = screen.encode(new Rectangle(0, 0, FlxG.width, FlxG.height), new PNGEncoderOptions());
	
	var i:Int = 1;
	while(FileSystem.exists(path + "/" + i + ".png")) {
		i++;
	}
	
	File.write(path + "/" + i + ".png", true);
	File.saveBytes(path + "/" + i + ".png", screenBytes);
}
  • Subsequently, I conducted tests and found that it was indeed possible to export the image of BF's death as PNG, and the effect was also very satisfactory

Image
Image

  • But soon, I discovered another problem

Image

  • I tested all the original songs in CodenameEngine, and eventually encountered an issue with the Week7 song. Here, camGame was responsible for displaying the screen.

  • there was no content displayed

  • Later, I discovered another issue, which is that objects in the scene cannot display transparency, only visible and invisible can be displayed

The fact is as follows:

  • screenshot
    Image

  • export
    Image

By this point, I'm almost at a loss. Can anyone help me?

Sincere thanks!!

@NexIsDumb
Copy link
Member

this is curious i see..
but could it be about vram stuff? i remember trying something similar but because of vram enabled i couldnt do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants