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


Java ConvertCmd.setOutputConsumer方法代码示例

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


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

示例1: convertWithOptions

import org.im4java.core.ConvertCmd; //导入方法依赖的package包/类
public byte[] convertWithOptions(InputStream image, String options) {
    String[] optionStrings = options.split(" ");
     
    IMOperation iMOperation = new IMOperation();
    iMOperation.addImage("-");
    iMOperation.addRawArgs(optionStrings);
    iMOperation.addImage(":-");
    
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    
    Pipe pipeIn  = new Pipe(image, null);
    Pipe pipeOut = new Pipe(null, byteArrayOutputStream);
    
    ConvertCmd convertCmd = new ConvertCmd();
    convertCmd.setInputProvider(pipeIn);
    convertCmd.setOutputConsumer(pipeOut);
    
    try {
        convertCmd.run(iMOperation);
    } catch (IOException | InterruptedException | IM4JavaException exception) {
        System.err.println(exception.getMessage());
    }
    
    return byteArrayOutputStream.toByteArray();
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:26,代码来源:ConvertFunction.java

示例2: convert2ImageFormat

import org.im4java.core.ConvertCmd; //导入方法依赖的package包/类
public static byte[] convert2ImageFormat(InputStream image, String format) throws IOException, InterruptedException, IM4JavaException {
    IMOperation iMOperation = new IMOperation();
    iMOperation.addImage("-");
    iMOperation.addImage( format + ":-");
    
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    
    Pipe pipeIn  = new Pipe(image, null);
    Pipe pipeOut = new Pipe(null, byteArrayOutputStream);
    
    ConvertCmd convertCmd = new ConvertCmd();
    convertCmd.setInputProvider(pipeIn);
    convertCmd.setOutputConsumer(pipeOut);
    convertCmd.run(iMOperation);
    
    return byteArrayOutputStream.toByteArray();
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:18,代码来源:Convert.java

示例3: resize

import org.im4java.core.ConvertCmd; //导入方法依赖的package包/类
protected static byte[] resize(InputStream image, Integer maxWidth, Integer maxHeight, String format, boolean keepAspectRatio) throws IOException, InterruptedException, IM4JavaException {
    IMOperation iMOperation = new IMOperation();
    iMOperation.addImage("-");
    
    if(!keepAspectRatio) {
        iMOperation.resize(maxWidth, maxHeight, '!');
    } else {
        iMOperation.resize(maxWidth, maxHeight);
    }
    iMOperation.addImage(format +  ":-");
    
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    
    Pipe pipeIn  = new Pipe(image, null);
    Pipe pipeOut = new Pipe(null, byteArrayOutputStream);
    
    ConvertCmd convertCmd = new ConvertCmd();
    convertCmd.setInputProvider(pipeIn);
    convertCmd.setOutputConsumer(pipeOut);
    convertCmd.run(iMOperation);

    return byteArrayOutputStream.toByteArray();
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:24,代码来源:Convert.java

示例4: crop

import org.im4java.core.ConvertCmd; //导入方法依赖的package包/类
static byte[] crop(InputStream image, int width, int height, int offsetX, int offsetY, String format, int rwidth, int rheight) throws IOException, InterruptedException, IM4JavaException {
    IMOperation iMOperation = new IMOperation();
    iMOperation.addImage("-");
    
    iMOperation.crop(width, height, offsetX, offsetY);
    iMOperation.repage(rwidth, rheight);
    
    iMOperation.addImage(format +  ":-");
    
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    
    Pipe pipeIn  = new Pipe(image, null);
    Pipe pipeOut = new Pipe(null, byteArrayOutputStream);
    
    ConvertCmd convertCmd = new ConvertCmd();
    convertCmd.setInputProvider(pipeIn);
    convertCmd.setOutputConsumer(pipeOut);
    convertCmd.run(iMOperation);
    
    return byteArrayOutputStream.toByteArray();
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:22,代码来源:Convert.java

示例5: rotate

import org.im4java.core.ConvertCmd; //导入方法依赖的package包/类
static byte[] rotate(InputStream image, double degrees, String format) throws IOException, InterruptedException, IM4JavaException {
    IMOperation iMOperation = new IMOperation();
    iMOperation.addImage("-");
    iMOperation.rotate(degrees);
    iMOperation.addImage(format +  ":-");
    
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    
    Pipe pipeIn  = new Pipe(image, null);
    Pipe pipeOut = new Pipe(null, byteArrayOutputStream);
    
    ConvertCmd convertCmd = new ConvertCmd();
    convertCmd.setInputProvider(pipeIn);
    convertCmd.setOutputConsumer(pipeOut);
    convertCmd.run(iMOperation);

    return byteArrayOutputStream.toByteArray();
}
 
开发者ID:exc-asia-and-europe,项目名称:imagemagick.xq,代码行数:19,代码来源:Convert.java


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