123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import { OpenSheetMusicDisplay, CanvasVexFlowBackend } from "../../src";
- import { TestUtils } from "./TestUtils";
- describe("GeneratePNGImages", () => {
-
- const sampleFilenames: string[] = [
- "Beethoven_AnDieFerneGeliebte.xml",
-
-
-
-
-
-
-
-
- "MuzioClementi_SonatinaOpus36No1_Part1.xml",
-
-
-
-
-
-
-
-
- ];
- for (const score of sampleFilenames) {
- generatePNG(score);
- }
-
-
- function generatePNG(sampleFilename: string): void {
- it(sampleFilename, (done: Mocha.Done) => {
-
- const score: Document = TestUtils.getScore(sampleFilename);
- const div: HTMLElement = document.createElement("div");
- const openSheetMusicDisplay: OpenSheetMusicDisplay =
- new OpenSheetMusicDisplay(div, { autoResize: false, backend: "canvas"});
- openSheetMusicDisplay.load(score);
- const testDir: string = "../data/images";
-
- const fileName: string = `${testDir}/${sampleFilename}.png`;
- console.log("fileName: " + fileName);
- console.log("before buffer");
- const canvasBackend: CanvasVexFlowBackend = openSheetMusicDisplay.Drawer.Backends[0] as CanvasVexFlowBackend;
- const imageData: string = (canvasBackend.getCanvas() as HTMLCanvasElement).toDataURL().split(";base64,").pop();
- const imageBuffer: Buffer = Buffer.from(imageData, "base64");
- console.log("imageBuffer.length: " + imageBuffer.length);
-
-
-
- done();
- }).timeout(30000);
- }
- });
|