public static void main(String[] args) throws Exception { // The path to the documents directory. String dataDir = Utils.getDataDir(ExportImageToPSD.class); // Load an existing image com.aspose.imaging.Image image = com.aspose.imaging.Image.load(dataDir + "sample.bmp"); // Create an instance of PsdSaveOptions class // Create an instance of PsdSaveOptions class com.aspose.imaging.imageoptions.PsdOptions saveOptions = new com.aspose.imaging.imageoptions.PsdOptions(); // Set the CompressionMethod as Raw // Note: Other supported CompressionMethod is CompressionMethod.Rle [No Compression] saveOptions.setCompressionMethod(CompressionMethod.Raw); // Set the ColorMode to GrayScale//Note: Other supported ColorModes are ColorModes.Bitmap and // ColorModes.RGB saveOptions.setColorMode(ColorModes.RGB); // Save the image to disk location with supplied PsdOptions settings image.save(dataDir + "output.psd", saveOptions); // Display Status. System.out.println("Image exported to PSD successfully!"); }
public static void main(String[] args) throws Exception { // The path to the documents directory. String dataDir = Utils.getSharedDataDir(DrawingRectangle.class) + "shapes/"; // Creates an instance of BmpOptions and set its various properties com.aspose.imaging.imageoptions.BmpOptions bmpCreateOptions = new com.aspose.imaging.imageoptions.BmpOptions(); bmpCreateOptions.setBitsPerPixel(32); // Define the source property for the instance of BmpOptions bmpCreateOptions.setSource( new com.aspose.imaging.sources.StreamSource( new java.io.ByteArrayInputStream(new byte[100 * 100 * 4]))); // Creates an instance of Image and call Create method by passing the bmpCreateOptionsobject com.aspose.imaging.Image image = com.aspose.imaging.Image.create(bmpCreateOptions, 100, 100); // Create and initialize an instance of Graphics class com.aspose.imaging.Graphics graphic = new com.aspose.imaging.Graphics(image); // Clear the image surface with Yellow color graphic.clear(com.aspose.imaging.Color.getYellow()); // Draw a dotted rectangle shape by specifying the Pen object having red color and a rectangle // structure graphic.drawRectangle( new Pen(com.aspose.imaging.Color.getRed()), new com.aspose.imaging.Rectangle(30, 10, 40, 80)); // Draw a continuous rectangle shape by specifying the Pen object having solid brush with blue // color and a rectangle structure graphic.drawRectangle( new Pen(new com.aspose.imaging.brushes.SolidBrush(com.aspose.imaging.Color.getBlue())), new com.aspose.imaging.Rectangle(10, 30, 80, 40)); // Save all changes. image.save(dataDir + "DrawingRectangle_out.bmp"); // Print message System.out.println("Rectangle created successfully. Check output file."); }
public static void main(String[] args) throws Exception { // The path to the documents directory. String dataDir = Utils.getSharedDataDir(ConcatTIFFImages.class) + "images/"; // Create an instance of TiffImage and load the copied destination image TiffImage image1 = (TiffImage) com.aspose.imaging.Image.load(dataDir + "TestDemo.tif"); // Create an instance of TiffImage and load the source image TiffImage image2 = (TiffImage) com.aspose.imaging.Image.load(dataDir + "sample.tif"); // Create an instance of TIffFrame and copy active frame of source image TiffFrame frame = TiffFrame.copyFrame(image2.getActiveFrame()); // Add copied frame to destination image image1.addFrame(frame); // save the image with changes. image1.save(); // Display Status. System.out.println("Concatenation of TIF files done successfully!"); }
public static void main(String... args) throws Exception { String dataDir = Utils.getSharedDataDir(CroppingWMFfileWhileConvertingtoPNG.class) + "wmf/"; String inputFileName = dataDir + "sample.wmf"; String outFileName = dataDir + "CroppingWMFfileWhileConvertingtoPNG.png"; // Load an existing WMF image com.aspose.imaging.Image image = com.aspose.imaging.Image.load( inputFileName, new com.aspose.imaging.imageloadoptions.MetafileLoadOptions(true)); try { // Create an instance of Rectangle class by passing x,y and // width,height // Caste the object to WmfImage class type // Call the crop method of Image class and pass the rectangle class // instance ((com.aspose.imaging.fileformats.wmf.WmfImage) image) .crop(new com.aspose.imaging.Rectangle(3000, 2000, 2000, 2000)); // Create an instance of EmfRasterizationOptions class and set // different properties com.aspose.imaging.imageoptions.EmfRasterizationOptions emf = new com.aspose.imaging.imageoptions.EmfRasterizationOptions(); emf.setPageWidth(2000); emf.setPageHeight(2000); emf.setBackgroundColor(com.aspose.imaging.Color.getWhiteSmoke()); // Create an instance of PngOptions class and provide rasterization // option ImageOptionsBase options = new PngOptions(); options.setVectorRasterizationOptions(emf); // Call the save method, provide output path and PngOptions to // convert the cropped WMF file to PNG and save the output image.save(outFileName, options); } finally { image.dispose(); } }
public static void main(String... args) throws Exception { // ExStart:ApplyMotionWienerFilter // The path to the documents directory. String dataDir = Utils.getSharedDataDir(ApplyMotionWienerFilter.class) + "ConvertingImages/"; Image image = Image.load(dataDir + "aspose-logo.gif"); // caste the image into RasterImage RasterImage rasterImage = (RasterImage) image; if (rasterImage == null) { return; } // Create an instance of MotionWienerFilterOptions class and set the // length, smooth value and angle. MotionWienerFilterOptions options = new MotionWienerFilterOptions(50, 9, 90); options.setGrayscale(true); // apply MedianFilterOptions filter to RasterImage object. rasterImage.filter(image.getBounds(), options); // Save the resultant image image.save(dataDir + "ApplyingMotionWienerFilter_out.gif"); // ExEnd:ApplyMotionWienerFilter }
public static void main(String[] args) throws Exception { // The path to the documents directory. String dataDir = Utils.getSharedDataDir(DrawingArc.class) + "images/"; // Creates an instance of BmpOptions and set its various properties com.aspose.imaging.imageoptions.BmpOptions bmpCreateOptions = new com.aspose.imaging.imageoptions.BmpOptions(); bmpCreateOptions.setBitsPerPixel(32); // Define the source property for the instance of BmpCreateOptions bmpCreateOptions.setSource( new com.aspose.imaging.sources.StreamSource( new java.io.ByteArrayInputStream(new byte[100 * 100 * 4]))); // Creates an instance of Image and call Create method by passing the // BmpOptions object com.aspose.imaging.Image image = com.aspose.imaging.Image.create(bmpCreateOptions, 100, 100); // Create and initialize an instance of Graphics class com.aspose.imaging.Graphics graphic = new com.aspose.imaging.Graphics(image); // Clear the image surface with Yellow color graphic.clear(com.aspose.imaging.Color.getYellow()); // Draw a dotted arc shape by specifying the Pen object having red black // color and coordinates, height, width, start & end angles int width = 100; int height = 200; int startAngle = 45; int sweepAngle = 270; // Draw arc to screen. graphic.drawArc( new Pen(com.aspose.imaging.Color.getBlack()), 0, 0, width, height, startAngle, sweepAngle); // Save all changes. image.save(dataDir + "DrawingArc_out.bmp"); }