コード例 #1
0
 public static function run($dataDir = null)
 {
     # Create an instance of BmpOptions and set its various properties
     $create_options = new BmpOptions();
     $create_options->setBitsPerPixel(32);
     # Define the source property for the instance of BmpOptions
     $ary = array();
     $create_options->setSource(new StreamSource(new ByteArrayInputStream($ary)));
     # Create an instance of Image
     $image = new Image();
     $image = $image->create($create_options, 100, 100);
     # Create an instance of Color
     $color = new Color();
     # Create an instance of Pen
     $pen = new Pen();
     # Create and initialize an instance of Graphics class
     $graphic = new Graphics($image);
     # Clear the image surface with Yellow color
     $graphic->clear($color->getYellow());
     $solid_brush = new SolidBrush();
     $rectangle = new Rectangle();
     # Draw a dotted ellipse shape by specifying the Pen object having red color and a surrounding Rectangle
     $graphic->drawEllipse(new Pen($color->getRed()), new Rectangle(30, 10, 40, 80));
     # Draw a continuous ellipse shape by specifying the Pen object having solid brush with blue color and a surrounding Rectangle
     $graphic->drawEllipse(new Pen(new SolidBrush($color->getBlue())), new Rectangle(10, 30, 80, 40));
     # Save all changes.
     $image->save($dataDir . "DrawEllipseExample.bmp");
     print "Ellipse have been drawn in image successfully!" . PHP_EOL;
 }
コード例 #2
0
 public static function run($dataDir = null)
 {
     # Create an instance of BmpOptions and set its various properties
     $create_options = new BmpOptions();
     $create_options->setBitsPerPixel(32);
     # Define the source property for the instance of BmpOptions
     $ary = array();
     $create_options->setSource(new StreamSource(new ByteArrayInputStream($ary)));
     # Create an instance of Image
     $image = new Image();
     $image = $image->create($create_options, 100, 100);
     # Create an instance of Color
     $color = new Color();
     # Create an instance of Pen
     $pen = new Pen();
     # Create and initialize an instance of Graphics class
     $graphic = new Graphics($image);
     # Clear the image surface with Yellow color
     $graphic->clear($color->getYellow());
     # Draw arc to screen.
     $graphic->drawArc(new Pen($color->getBlack()), 0, 0, 100, 200, 45, 270);
     # Save all changes.
     $image->save($dataDir . "DrawArcExample.bmp");
     print "Arc have been drawn in image successfully!" . PHP_EOL;
 }
 public static function run($dataDir = null)
 {
     # Create an instance of BmpOptions and set its various properties
     $create_options = new BmpOptions();
     $create_options->setBitsPerPixel(24);
     # Create an instance of FileCreateSource and assign it to Source property
     $fileCreateSource = new FileCreateSource();
     $create_options->setSource(new FileCreateSource($dataDir . "sample.bmp", false));
     # Create an instance of RasterImage
     $image = new Image();
     $raster_image = $image->create($create_options, 500, 500);
     # Get the pixels of the image by specifying the area as image boundary
     $pixels = $raster_image->loadPixels($raster_image->getBounds());
     $index = 0;
     while ($index < sizeof($pixels)) {
         # Set the indexed pixel color to yellow
         $color = new Color();
         $pixels[$index] = $color->getYellow();
         $index += 1;
     }
     $raster_image->savePixels($raster_image->getBounds(), $pixels);
     # save all changes
     $raster_image->save();
     print "Draw Images Using Core Functionality." . PHP_EOL;
 }
 public static function run($dataDir = null)
 {
     # Load an existing image (of type bmp) in an instance of Image class
     $image = new Image();
     $image = $image->load($dataDir . "demo.djvu");
     # Create an instance of BmpOptions
     $export_options = new BmpOptions();
     # Set BitsPerPixel for resultant images
     $export_options->setBitsPerPixel(32);
     # Create an instance of IntRange and initialize it with range of pages to be exported
     $range = [0, 1];
     #Export first 2 pages
     $i = 0;
     while ($i < 2) {
         # Save each page in separate file, as BMP do not support layering
         $export_options->setMultiPageOptions(new DjvuMultiPageOptions($i));
         $image->save($dataDir . "djvupages#{i}.bmp", $export_options);
         $i += 1;
     }
     # Display Status.
     print "Converted range of DjVu pages to separate images successfully!" . PHP_EOL;
 }
 public static function run($dataDir = null)
 {
     # Create an instance of BmpOptions and set its various properties
     $create_options = new BmpOptions();
     $create_options->setBitsPerPixel(24);
     # Create an instance of FileCreateSource and assign it to Source property
     $create_options->setSource(new FileCreateSource($dataDir . "DrawingImageUsingGraphics.bmp", false));
     # Create an instance of Image
     $image = new Image();
     $image = $image->create($create_options, 500, 500);
     # Create and initialize an instance of Graphics
     $graphics = new Graphics($image);
     # Clear the image surface with white color
     $color = new Color();
     $graphics->clear($color->getWhite());
     # Create and initialize a Pen object with blue color
     $pen = new Pen($color->getBlue());
     # Draw Ellipse by defining the bounding rectangle of width 150 and height 100
     $graphics->drawEllipse($pen, new Rectangle(10, 10, 150, 100));
     # save all changes
     $image->save();
     print "Created image using graphics." . PHP_EOL;
 }
コード例 #6
0
 public static function run($dataDir = null)
 {
     # Create an instance of BmpOptions and set its various properties
     $create_options = new BmpOptions();
     $create_options->setBitsPerPixel(32);
     # Define the source property for the instance of BmpOptions
     $ary = array();
     $create_options->setSource(new StreamSource(new ByteArrayInputStream($ary)));
     # Create an instance of Image
     $image = new Image();
     $image = $image->create($create_options, 100, 100);
     # Create an instance of Color
     $color = new Color();
     # Create an instance of Pen
     $pen = new Pen();
     # Create and initialize an instance of Graphics class
     $graphic = new Graphics($image);
     # Clear the image surface with Yellow color
     $graphic->clear($color->getYellow());
     # Draw a dotted line by specifying the Pen object having blue color and co-ordinate Points
     $graphic->drawLine(new Pen($color->getBlue()), 9, 9, 90, 90);
     $graphic->drawLine(new Pen($color->getBlue()), 9, 90, 90, 9);
     $solid_brush = new SolidBrush();
     $point = new Point();
     # Draw a continuous line by specifying the Pen object having Solid Brush with red color and two point structures
     $graphic->drawLine(new Pen(new SolidBrush($color->getRed())), new Point(9, 9), new Point(9, 90));
     # Draw a continuous line by specifying the Pen object having Solid Brush with aqua color and two point structures
     $graphic->drawLine(new Pen(new SolidBrush($color->getAqua())), new Point(9, 90), new Point(90, 90));
     # Draw a continuous line by specifying the Pen object having Solid Brush with black color and two point structures
     $graphic->drawLine(new Pen(new SolidBrush($color->getBlack())), new Point(90, 90), new Point(90, 9));
     # Draw a continuous line by specifying the Pen object having Solid Brush with white color and two point structures
     $graphic->drawLine(new Pen(new SolidBrush($color->getWhite())), new Point(90, 9), new Point(9, 9));
     # Save all changes.
     $image->save($dataDir . "DrawLinesExample.bmp");
     print "Lines have been drawn in image successfully!" . PHP_EOL;
 }