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;
 }
 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)
 {
     # Create an instance of PsdOptions and set it's properties
     $create_options = new PsdOptions();
     # Set source
     $create_options->setSource(new FileCreateSource($dataDir . "CreatePSD.psd", false));
     # Set ColorMode to Indexed
     $colorModes = new ColorModes();
     $create_options->setColorMode($colorModes->Indexed);
     # Set PSD file version
     $create_options->setVersion(5);
     $color = new Color();
     # Create a new color patelle having RGB colors
     $palette = [$color->getRed(), $color->getGreen(), $color->getBlue()];
     # Set Palette property to newly created palette
     $create_options->setPalette(new PsdColorPalette($palette));
     # Set compression method
     $compressionMethod = new CompressionMethod();
     $create_options->setCompressionMethod($compressionMethod->RLE);
     # Create a new PSD with PsdOptions created previously
     $psdImage = new PsdImage();
     $psd = $psdImage->create($create_options, 500, 500);
     # Draw some graphics over the newly created PSD
     $graphics = new Graphics($psd);
     $graphics->clear($color->getWhite());
     $graphics->drawEllipse(new Pen($color->getRed(), 6), new Rectangle(0, 0, 400, 400));
     $psd->save();
     # Display Status.
     print "Created PSD 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;
 }
 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;
 }