1 50 51 package org.openlaszlo.iv.flash.commands; 52 53 import java.io.*; 54 import org.openlaszlo.iv.flash.parser.*; 55 import org.openlaszlo.iv.flash.api.*; 56 import org.openlaszlo.iv.flash.api.image.*; 57 import org.openlaszlo.iv.flash.api.shape.*; 58 import org.openlaszlo.iv.flash.util.*; 59 import org.openlaszlo.iv.flash.cache.*; 60 import org.openlaszlo.iv.flash.url.*; 61 62 import org.openlaszlo.iv.flash.context.Context; 63 64 public class InsertJpegFileCommand extends GenericCommand { 65 66 public InsertJpegFileCommand() {} 67 68 public void doCommand( FlashFile file, Context context, Script parent, int frame ) throws IVException { 69 String filename = getParameter( context, "filename", "" ); 70 boolean scale = getBoolParameter( context, "scale", false ); 71 String export = getParameter( context, "export", "JPEG" ); 72 int quality = getIntParameter( context, "quality", 100 ); 73 boolean cache = getBoolParameter( context, "cache", false ); 74 String instancename = getParameter( context, "instancename" ); 75 76 JPEGBitmap bitmap = null; 77 try { 78 bitmap = (JPEGBitmap) file.addExternalMedia(filename, cache); 79 } catch( IOException e ) { 80 throw new IVException(Resource.ERRCMDFILEREAD, new Object [] {filename, getCommandName()}, e); 81 } 82 83 if( quality < 100 ) { 84 bitmap.processImage( quality/100f ); 85 } 86 87 Instance myInst = bitmap.newInstance( 2048, 2048, scale, true ); 88 89 Instance inst = getInstance(); 90 Script script = inst.copyScript(); 91 Frame myFrame = script.newFrame(); 92 myFrame.addInstance( myInst, 1 ); 93 94 if( instancename != null ) { 95 inst.name = instancename; 96 } 97 } 98 99 } 100 | Popular Tags |