本文整理汇总了Java中org.apache.batik.transcoder.image.ImageTranscoder.addTranscodingHint方法的典型用法代码示例。如果您正苦于以下问题:Java ImageTranscoder.addTranscodingHint方法的具体用法?Java ImageTranscoder.addTranscodingHint怎么用?Java ImageTranscoder.addTranscodingHint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.batik.transcoder.image.ImageTranscoder
的用法示例。
在下文中一共展示了ImageTranscoder.addTranscodingHint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTestImageTranscoder
import org.apache.batik.transcoder.image.ImageTranscoder; //导入方法依赖的package包/类
/**
* Returns the <code>ImageTranscoder</code> the Test should
* use
*/
public ImageTranscoder getTestImageTranscoder(){
ImageTranscoder t = new InternalPNGTranscoder();
t.addTranscodingHint(PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE,
Boolean.FALSE);
t.addTranscodingHint(PNGTranscoder.KEY_BACKGROUND_COLOR,
new Color(0,0,0,0));
t.addTranscodingHint(PNGTranscoder.KEY_EXECUTE_ONLOAD,
Boolean.TRUE);
if (validate){
t.addTranscodingHint(PNGTranscoder.KEY_XML_PARSER_VALIDATING,
Boolean.TRUE);
t.addTranscodingHint(PNGTranscoder.KEY_XML_PARSER_CLASSNAME,
VALIDATING_PARSER);
}
if (userLanguage != null){
t.addTranscodingHint(PNGTranscoder.KEY_LANGUAGE,
userLanguage);
}
return t;
}
示例2: readInput
import org.apache.batik.transcoder.image.ImageTranscoder; //导入方法依赖的package包/类
protected void readInput(final PipelineContext context, final ProcessorInput input, Config config, OutputStream outputStream) {
try {
//JPEGTranscoder t = new JPEGTranscoder();
final ImageTranscoder imageTranscoder = new PNGTranscoder();
imageTranscoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(0.8));
//t.addTranscodingHint(JPEGTranscoder.KEY_WIDTH, new Integer(100));
//trans.addTranscodingHint(JPEGTranscoder.KEY_AOI, aoi);
//Document document = readInputAsDOM4J(context, input);
//String documentString = XMLUtils.domToString(document);
//TranscoderInput ti = new TranscoderInput(new StringReader(documentString));
//TranscoderInput tixxx1 = new TranscoderInput(document);
final TranscoderInput transcoderInput = new TranscoderInput(new XMLReaderToReceiver() {
@Override
public void parse(String systemId) throws SAXException {
readInputAsSAX(context, (input != null) ? input : getInputByName(INPUT_DATA), createXMLReceiver());
}
});
final TranscoderOutput transcoderOutput = new TranscoderOutput(outputStream);
imageTranscoder.transcode(transcoderInput, transcoderOutput);
} catch (Exception e) {
throw new OXFException(e);
}
}
示例3: setupTranscoder
import org.apache.batik.transcoder.image.ImageTranscoder; //导入方法依赖的package包/类
private void setupTranscoder(ImageTranscoder t, SVGDocument doc) throws TranscoderException {
UserAgent userAgent = new UserAgentAdapter();
DocumentLoader loader = new DocumentLoader(userAgent);
BridgeContext ctx = new BridgeContext(userAgent, loader);
ctx.setDynamicState(BridgeContext.DYNAMIC);
GVTBuilder builder = new GVTBuilder();
GraphicsNode rootGN = builder.build(ctx, doc);
Rectangle2D bounds = rootGN.getBounds();
double pageWidth = settings.getPropertyDouble(PROPERTY_PAGE_WIDTH, DEFAULT_PAGE_WIDTH) * dpi;
double pageHeight = settings.getPropertyDouble(PROPERTY_PAGE_HEIGHT, DEFAULT_PAGE_HEIGHT) * dpi;
Point2D.Double scaledSize = getScaledSize(bounds.getWidth(), bounds.getHeight(), pageWidth, pageHeight);
System.out.println("Target size = " + pageWidth + "x" + pageHeight);
System.out.println("Scaled size = " + scaledSize.getX() + "x" + scaledSize.getY());
t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, (float) scaledSize.getX());
t.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, (float)scaledSize.getY());
t.addTranscodingHint(PNGTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, 25.4f / 300.0f);
}
示例4: getTestImageTranscoder
import org.apache.batik.transcoder.image.ImageTranscoder; //导入方法依赖的package包/类
/**
* Returns the <code>ImageTranscoder</code> the Test should
* use
*/
public ImageTranscoder getTestImageTranscoder(){
ImageTranscoder t = super.getTestImageTranscoder();
t.addTranscodingHint(PNGTranscoder.KEY_ALTERNATE_STYLESHEET,
parameter);
return t;
}
示例5: actionPerformed
import org.apache.batik.transcoder.image.ImageTranscoder; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
JFileChooser fileChooser =
new JFileChooser(makeAbsolute(currentSavePath));
fileChooser.setDialogTitle(resources.getString("ExportAsJPG.title"));
fileChooser.setFileHidingEnabled(false);
fileChooser.setFileSelectionMode
(JFileChooser.FILES_ONLY);
fileChooser.addChoosableFileFilter(new ImageFileFilter(".jpg"));
int choice = fileChooser.showSaveDialog(JSVGViewerFrame.this);
if (choice == JFileChooser.APPROVE_OPTION) {
float quality =
JPEGOptionPanel.showDialog(JSVGViewerFrame.this);
final File f = fileChooser.getSelectedFile();
BufferedImage buffer = svgCanvas.getOffScreen();
if (buffer != null) {
statusBar.setMessage
(resources.getString("Message.exportAsJPG"));
// create a BufferedImage of the appropriate type
int w = buffer.getWidth();
int h = buffer.getHeight();
final ImageTranscoder trans = new JPEGTranscoder();
if (application.getXMLParserClassName() != null) {
trans.addTranscodingHint
(JPEGTranscoder.KEY_XML_PARSER_CLASSNAME,
application.getXMLParserClassName());
}
trans.addTranscodingHint
(JPEGTranscoder.KEY_QUALITY, new Float(quality));
final BufferedImage img = trans.createImage(w, h);
// paint the buffer to the image
Graphics2D g2d = img.createGraphics();
g2d.setColor(Color.white);
g2d.fillRect(0, 0, w, h);
g2d.drawImage(buffer, null, 0, 0);
new Thread() {
public void run() {
try {
currentSavePath = f;
OutputStream ostream =
new BufferedOutputStream(new FileOutputStream(f));
trans.writeImage(img, new TranscoderOutput(ostream));
ostream.close();
} catch (Exception ex) { }
statusBar.setMessage
(resources.getString("Message.done"));
}
}.start();
}
}
}
示例6: getTestImageTranscoder
import org.apache.batik.transcoder.image.ImageTranscoder; //导入方法依赖的package包/类
/**
* Returns the <code>ImageTranscoder</code> the Test should
* use
*/
public ImageTranscoder getTestImageTranscoder(){
ImageTranscoder t = super.getTestImageTranscoder();
t.addTranscodingHint(PNGTranscoder.KEY_MEDIA, parameter);
return t;
}