Search in sources :

Example 1 with PngScoreDocFileOutput

use of com.xenoage.zong.desktop.io.png.out.PngScoreDocFileOutput in project Zong by Xenoage.

the class Content method saveAs.

/**
 * Saves the current score using the given format.
 * pdf, png, mid and ogg is supported by this demo.
 */
public void saveAs(String format) {
    FileOutput<ScoreDoc> out = null;
    switch(format) {
        case "pdf":
            out = new PdfScoreDocFileOutput();
            break;
        case "png":
            out = new PngScoreDocFileOutput();
            break;
        case "mid":
            out = new MidiScoreDocFileOutput();
            break;
        case "ogg":
            out = new OggScoreDocFileOutput();
            break;
        default:
            return;
    }
    String filePath = "demo." + format;
    try {
        DocumentIO.write(scoreDoc, new File(filePath), out);
        mainWindow.showMessageDialog(filePath + " saved.");
    } catch (Exception ex) {
        Err.handle(Report.Companion.error(ex));
    }
}
Also used : PngScoreDocFileOutput(com.xenoage.zong.desktop.io.png.out.PngScoreDocFileOutput) OggScoreDocFileOutput(com.xenoage.zong.desktop.io.ogg.out.OggScoreDocFileOutput) PdfScoreDocFileOutput(com.xenoage.zong.desktop.io.pdf.out.PdfScoreDocFileOutput) MidiScoreDocFileOutput(com.xenoage.zong.desktop.io.midi.out.MidiScoreDocFileOutput) File(java.io.File) ScoreDoc(com.xenoage.zong.documents.ScoreDoc)

Example 2 with PngScoreDocFileOutput

use of com.xenoage.zong.desktop.io.png.out.PngScoreDocFileOutput in project Zong by Xenoage.

the class VisualHtmlReport method renderScore.

/**
 * Renders the given score into an image file.
 */
private void renderScore(File scoreFile) throws IOException {
    ScoreDoc doc = DocumentIO.read(scoreFile, new MusicXmlScoreDocFileInput());
    File pngFile = new File(new File(dirReport, appDir), scoreFile.getName() + ".png");
    DocumentIO.write(doc, pngFile, new PngScoreDocFileOutput());
    cropScoreImage(pngFile);
}
Also used : PngScoreDocFileOutput(com.xenoage.zong.desktop.io.png.out.PngScoreDocFileOutput) MusicXmlScoreDocFileInput(com.xenoage.zong.desktop.io.musicxml.in.MusicXmlScoreDocFileInput) File(java.io.File) ScoreDoc(com.xenoage.zong.documents.ScoreDoc)

Aggregations

PngScoreDocFileOutput (com.xenoage.zong.desktop.io.png.out.PngScoreDocFileOutput)2 ScoreDoc (com.xenoage.zong.documents.ScoreDoc)2 File (java.io.File)2 MidiScoreDocFileOutput (com.xenoage.zong.desktop.io.midi.out.MidiScoreDocFileOutput)1 MusicXmlScoreDocFileInput (com.xenoage.zong.desktop.io.musicxml.in.MusicXmlScoreDocFileInput)1 OggScoreDocFileOutput (com.xenoage.zong.desktop.io.ogg.out.OggScoreDocFileOutput)1 PdfScoreDocFileOutput (com.xenoage.zong.desktop.io.pdf.out.PdfScoreDocFileOutput)1