当前位置: 首页>>代码示例>>Java>>正文


Java Transcoder.setTranscodingHints方法代码示例

本文整理汇总了Java中org.apache.batik.transcoder.Transcoder.setTranscodingHints方法的典型用法代码示例。如果您正苦于以下问题:Java Transcoder.setTranscodingHints方法的具体用法?Java Transcoder.setTranscodingHints怎么用?Java Transcoder.setTranscodingHints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.batik.transcoder.Transcoder的用法示例。


在下文中一共展示了Transcoder.setTranscodingHints方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convert

import org.apache.batik.transcoder.Transcoder; //导入方法依赖的package包/类
private void convert(String svgFileName, String pngFileName)
{
	Transcoder transcoder = new PNGTranscoder();
       Map<TranscodingHints.Key, Float> hints = 
       	new HashMap<TranscodingHints.Key, Float>();
       hints.put(ImageTranscoder.KEY_MAX_HEIGHT, new Float(750));
       hints.put(ImageTranscoder.KEY_MAX_WIDTH, new Float(750));
       transcoder.setTranscodingHints(hints);
	
       try {
        TranscoderInput input = 
        	new TranscoderInput(new File(svgFileName).toURI().toString());
		TranscoderOutput output =
			new TranscoderOutput(new FileOutputStream(pngFileName));
	
		transcoder.transcode(input, output);
	} catch (Exception e) {
		throw new RuntimeException("Transcoding failed.", e);
	}
}
 
开发者ID:donkirkby,项目名称:donkirkby,代码行数:21,代码来源:PaintWriter.java

示例2: convert

import org.apache.batik.transcoder.Transcoder; //导入方法依赖的package包/类
private void convert(String svgFileName, String pngFileName)
{
	Transcoder transcoder = new PNGTranscoder();
       Map<TranscodingHints.Key, Float> hints = 
       	new HashMap<TranscodingHints.Key, Float>();
       hints.put(ImageTranscoder.KEY_MAX_HEIGHT, new Float(200));
       hints.put(ImageTranscoder.KEY_MAX_WIDTH, new Float(750));
       transcoder.setTranscodingHints(hints);
	
       try {
        TranscoderInput input = 
        	new TranscoderInput(new File(svgFileName).toURI().toString());
		TranscoderOutput output =
			new TranscoderOutput(new FileOutputStream(pngFileName));
	
		transcoder.transcode(input, output);
	} catch (Exception e) {
		throw new RuntimeException("Transcoding failed.", e);
	}
}
 
开发者ID:donkirkby,项目名称:donkirkby,代码行数:21,代码来源:PaintWriter.java

示例3: execute

import org.apache.batik.transcoder.Transcoder; //导入方法依赖的package包/类
/**
 * Starts the conversion process.
 * @throws SVGConverterException thrown if parameters are not set correctly.
 */
public void execute() throws SVGConverterException {
    // Compute the set of SVGConverterSource from the source properties
    // (srcDir and srcFile);
    // This throws an exception if there is not at least one src file.
    List sources = computeSources();

    // Compute the destination files from dest
    List dstFiles = null;
    if(sources.size() == 1 && dst != null && isFile(dst)){
        dstFiles = new ArrayList();
        dstFiles.add(dst);
    }
    else{
        dstFiles = computeDstFiles(sources);
    }

    // Now, get the transcoder to use for the operation
    Transcoder transcoder = destinationType.getTranscoder();
    if(transcoder == null) {
        throw new SVGConverterException(ERROR_CANNOT_ACCESS_TRANSCODER,
                                         new Object[]{destinationType.toString()},
                                         true /* fatal error */);
    }

    // Now, compute the set of transcoding hints to use
    Map hints = computeTranscodingHints();
    transcoder.setTranscodingHints(hints);

    // Notify listener that task has been computed
    if(!controller.proceedWithComputedTask(transcoder,
                                           hints,
                                           sources,
                                           dstFiles)){
        return;
    }

    // Convert files one by one
    for(int i = 0 ; i < sources.size() ; i++) {
        // Get the file from the vector.
        SVGConverterSource currentFile
            = (SVGConverterSource)sources.get(i);
        File outputFile  = (File)dstFiles.get(i);

        createOutputDir(outputFile);
        transcode(currentFile, outputFile, transcoder);
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:52,代码来源:SVGConverter.java

示例4: main

import org.apache.batik.transcoder.Transcoder; //导入方法依赖的package包/类
/**
 * @param args
 * @throws IOException 
 * @throws TranscoderException 
 */
public static void main(String[] args) throws IOException, TranscoderException {
	
	InputStream resourceAsStream = SVGMainTests.class.getResourceAsStream("/br/com/dlp/jazzav/modeloanuncio/teste.svg");
	
	InputStream fis = resourceAsStream;
	
	FileOutputStream fos = new FileOutputStream("teste.png");
	
	Transcoder transcoder = new PNGTranscoder(); 
	
	Map hintMap = new HashMap();
	
	hintMap.put(PNGTranscoder.KEY_BACKGROUND_COLOR,Color.BLACK);
	
	
	
	
	transcoder.setTranscodingHints(hintMap);
	
	
	
	TranscoderInput in = new TranscoderInput(fis);
	TranscoderOutput out = new TranscoderOutput(fos);
	
	transcoder.transcode(in, out);
	
	fos.flush();
	fos.close();
	
	/*
	AffineTransform xform = new AffineTransform();
	
	xform.rotate(Math.toRadians(30));
	
	AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
	*/
	
}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:44,代码来源:SVGMainTests.java

示例5: paint

import org.apache.batik.transcoder.Transcoder; //导入方法依赖的package包/类
public void paint(OutputStream out, Object data) throws IOException, TemplateException {

		InputStream svgStream = SVGMainTests.class.getResourceAsStream("/br/com/dlp/jazzav/modeloanuncio/teste.svg");
		String modeloAnuncio = IOUtils.toString(svgStream);
		
		
		String strSVG = modeloAnuncio.replaceAll("&quot;", "\"");
				
		StringReader reader = new StringReader(strSVG);
		
		Configuration cfg = new Configuration();
		
		
		
		Template template = new Template("teste", reader, cfg,"UTF-16");
		
		
		Map rootMap = new HashMap();
		
		rootMap.put("anuncio", anuncioVO);
		
		StringWriter writer = new StringWriter();
		
		template.process(rootMap, writer);
		
		
		
		
		svgStream = IOUtils.toInputStream(writer.getBuffer().toString());
		
		
		Transcoder transcoder = new PNGTranscoder(); 
		
		Map hintMap = new HashMap();
		
		hintMap.put(PNGTranscoder.KEY_WIDTH, 400f);
		hintMap.put(PNGTranscoder.KEY_HEIGHT, 300f);
		
		transcoder.setTranscodingHints(hintMap);
		
		TranscoderInput in = new TranscoderInput(svgStream);
		TranscoderOutput tout = new TranscoderOutput(out);
		
		try {
			transcoder.transcode(in, tout);
		} catch (TranscoderException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		out.flush();
		out.close();
	}
 
开发者ID:darciopacifico,项目名称:omr,代码行数:54,代码来源:AnuncioBean.java


注:本文中的org.apache.batik.transcoder.Transcoder.setTranscodingHints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。