private byte[] Encode(WsqEncoder enc, Bitmap image) { if (rbQuality.Checked) { return(enc.EncodeQualityGdi(image, (int)nudQuality.Value)); } else if (rbCompressionRatio.Checked) { return(enc.EncodeCompressionRatioGdi(image, (int)nudCompressionRatio.Value)); } else if (rbBitrate.Checked) { return(enc.EncodeGdi(image, (float)nudBitrate.Value)); } else { throw new Exception("???"); } }
protected override void OnSaveT(Document input, Stream output, PropertyBasedSaveConfigToken token, Surface scratchSurface, ProgressEventHandler progressCallback) { var quality = (int)token.GetProperty(PropertyNames.Quality).Value; var comment = (string)token.GetProperty(PropertyNames.Comment).Value; using (var args = new RenderArgs(scratchSurface)) input.Render(args, false); var enc = new WsqEncoder(); byte[] bytes = null; using (var bitmap = scratchSurface.CreateAliasedBitmap()) { SetResolution(bitmap, input); enc.Comment = comment; bytes = enc.EncodeQualityGdi(bitmap, quality); } if (bytes != null) { output.Write(bytes, 0, (int)bytes.Length); } }