Creates a new image.

@param width Number of columns in the image.
@param height Number of rows in the image.
@return New instance of the image.
2208
public T createImage( int width , int height ) {
		switch( family ) {
			case GRAY:
				return (T)GeneralizedImageOps.createSingleBand(getImageClass(),width,height);

			case INTERLEAVED:
				return (T)GeneralizedImageOps.createInterleaved(getImageClass(), width, height, numBands);

			case PLANAR:
				return (T)new Planar(getImageClass(),width,height,numBands);

			default:
				throw new IllegalArgumentException("Type not yet supported");
		}
	}
921807
@Override
    public final AbstractGauge init(final int WIDTH, final int HEIGHT) {
        if (WIDTH <= 1 || HEIGHT <= 1) {
            return this;
        }
        if (isLcdVisible()) {
            if (isDigitalFont()) {
                setLcdValueFont(getModel().getDigitalBaseFont().deriveFont(0.7f * WIDTH * 0.15f));
            } else {
                setLcdValueFont(getModel().getStandardBaseFont().deriveFont(0.625f * WIDTH * 0.15f));
            }

            if (isCustomLcdUnitFontEnabled()) {
                setLcdUnitFont(getCustomLcdUnitFont().deriveFont(0.25f * WIDTH * 0.15f));
            } else {
                setLcdUnitFont(getModel().getStandardBaseFont().deriveFont(0.25f * WIDTH * 0.15f));
            }

            setLcdInfoFont(getModel().getStandardInfoFont().deriveFont(0.15f * WIDTH * 0.15f));
        }
        // Create Background Image
        if (bImage != null) {
            bImage.flush();
        }
        bImage = UTIL.createImage(WIDTH, WIDTH, Transparency.TRANSLUCENT);

        // Create Foreground Image
        if (fImage != null) {
            fImage.flush();
        }
        fImage = UTIL.createImage(WIDTH, WIDTH, Transparency.TRANSLUCENT);

        if (isFrameVisible()) {
            switch (getFrameType()) {
                case ROUND:
                    FRAME_FACTORY.createRadialFrame(WIDTH, getFrameDesign(), getCustomFrameDesign(), getFrameEffect(), bImage);
                    break;
                case SQUARE:
                    FRAME_FACTORY.createLinearFrame(WIDTH, WIDTH, getFrameDesign(), getCustomFrameDesign(), getFrameEffect(), bImage);
                    break;
                default:
                    FRAME_FACTORY.createRadialFrame(WIDTH, getFrameDesign(), getCustomFrameDesign(), getFrameEffect(), bImage);
                    break;
            }
        }

        if (isBackgroundVisible()) {
            create_BACKGROUND_Image(WIDTH, "", "", bImage);
        }

        if (isForegroundVisible()) {
            switch (getFrameType()) {
                case SQUARE:
                    FOREGROUND_FACTORY.createLinearForeground(WIDTH, WIDTH, false, bImage);
                    break;

                case ROUND:

                default:
                    FOREGROUND_FACTORY.createRadialForeground(WIDTH, false, getForegroundType(), fImage);
                    break;
            }
        }

        if (isLcdVisible()) {
            createLcdImage(new Rectangle2D.Double(((getGaugeBounds().width - WIDTH * 0.48) / 2.0), (getGaugeBounds().height * 0.425), (WIDTH * 0.48), (WIDTH * 0.15)), getLcdColor(), getCustomLcdBackground(), bImage);
            LCD.setRect(((getGaugeBounds().width - WIDTH * 0.4) / 2.0), (getGaugeBounds().height * 0.55), WIDTH * 0.48, WIDTH * 0.15);

            // Create the lcd threshold indicator image
            if (lcdThresholdImage != null) {
                lcdThresholdImage.flush();
            }
            lcdThresholdImage = create_LCD_THRESHOLD_Image((int) (LCD.getHeight() * 0.2045454545), (int) (LCD.getHeight() * 0.2045454545), getLcdColor().TEXT_COLOR);
        }

        if (disabledImage != null) {
            disabledImage.flush();
        }
        disabledImage = create_DISABLED_Image(WIDTH);

        ledPosition = new java.awt.Point[]{
            // LED 1
            new java.awt.Point((int) (WIDTH * 0.186915887850467), (int) (WIDTH * 0.649532710280374)),
            // LED 2
            new java.awt.Point((int) (WIDTH * 0.116822429906542), (int) (WIDTH * 0.546728971962617)),
            // LED 3
            new java.awt.Point((int) (WIDTH * 0.088785046728972), (int) (WIDTH * 0.41588785046729)),
            // LED 4
            new java.awt.Point((int) (WIDTH * 0.116822429906542), (int) (WIDTH * 0.285046728971963)),
            // LED 5
            new java.awt.Point((int) (WIDTH * 0.177570093457944), (int) (WIDTH * 0.182242990654206)),
            // LED 6
            new java.awt.Point((int) (WIDTH * 0.280373831775701), (int) (WIDTH * 0.117222429906542)),
            // LED 7
            new java.awt.Point((int) (WIDTH * 0.411214953271028), (int) (WIDTH * 0.0794392523364486)),
            // LED 8
            new java.awt.Point((int) (WIDTH * 0.542056074766355), (int) (WIDTH * 0.117222429906542)),
            // LED 9
            new java.awt.Point((int) (WIDTH * 0.649532710280374), (int) (WIDTH * 0.182242990654206)),
            // LED 10
            new java.awt.Point((int) (WIDTH * 0.719626168224299), (int) (WIDTH * 0.285046728971963)),
            // LED 11
            new java.awt.Point((int) (WIDTH * 0.738317757009346), (int) (WIDTH * 0.41588785046729)),
            // LED 12
            new java.awt.Point((int) (WIDTH * 0.710280373831776), (int) (WIDTH * 0.546728971962617)),
            // LED 13
            new java.awt.Point((int) (WIDTH * 0.64018691588785), (int) (WIDTH * 0.649532710280374))
        };
        ledGreenOff.flush();
        ledGreenOff = create_LED_OFF_Image(WIDTH, LedColor.GREEN);
        ledYellowOff.flush();
        ledYellowOff = create_LED_OFF_Image(WIDTH, LedColor.YELLOW);
        ledRedOff.flush();
        ledRedOff = create_LED_OFF_Image(WIDTH, LedColor.RED);
        ledGreenOn.flush();
        ledGreenOn = create_LED_ON_Image(WIDTH, LedColor.GREEN);
        ledYellowOn.flush();
        ledYellowOn = create_LED_ON_Image(WIDTH, LedColor.YELLOW);
        ledRedOn.flush();
        ledRedOn = create_LED_ON_Image(WIDTH, LedColor.RED);

        return this;
    }
255904
public function createThumbnail($name, $width, $height)
    {
        $this->addAction('thumbnail', $name, $width, $height);
        return $this;
    }
432949
private BufferedImage createSparkLineImage(final int WIDTH, final int HEIGHT) {
        if (WIDTH <= 0 || HEIGHT <= 0) {
            return null;
        }

        final BufferedImage IMAGE = UTIL.createImage(WIDTH, HEIGHT, Transparency.TRANSLUCENT);
        final Graphics2D G2 = IMAGE.createGraphics();

        if (!pointList.isEmpty()) {
            G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            //G2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);

            // Generate sparkline and filled sparkline
            final GeneralPath SPARK_LINE = new GeneralPath();
            final GeneralPath SPARK_LINE_FILLED = new GeneralPath();

            SPARK_LINE_FILLED.moveTo(pointList.get(0).getX(), baseLineY);

            SPARK_LINE.moveTo(pointList.get(0).getX(), HEIGHT - pointList.get(0).getY());
            SPARK_LINE_FILLED.lineTo(pointList.get(0).getX(), HEIGHT - pointList.get(0).getY());

            for (Point2D point : pointList) {
                SPARK_LINE.lineTo(point.getX(), HEIGHT - point.getY());
                SPARK_LINE_FILLED.lineTo(point.getX(), HEIGHT - point.getY());
            }

            SPARK_LINE_FILLED.lineTo(pointList.get(pointList.size() - 1).getX(), baseLineY);
            SPARK_LINE_FILLED.closePath();

            // Draw sparkline
            G2.setStroke(new BasicStroke(this.lineWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER));

            if (filled) {
                final Point2D START_POINT = new Point2D.Double(0, INNER_BOUNDS.y);
                final Point2D END_POINT = new Point2D.Double(0, INNER_BOUNDS.y + INNER_BOUNDS.height);
                if (START_POINT.equals(END_POINT)) {
                    END_POINT.setLocation(0.0, START_POINT.getY() + 1);
                }
                float baseLineFraction = (float) (baseLineY / INNER_BOUNDS.height);
                if (baseLineFraction < 0f || baseLineFraction > 1f) {
                    baseLineFraction = 0.5f;
                }
                if (START_POINT.distance(END_POINT) != 0) {
                    float[] fractions = {
                        0.0f,
                        baseLineFraction,
                        1.0f
                    };

                    // Set appropriate filling gradient
                    final Color[] COLORS;
                    if (areaFill == ColorDef.CUSTOM) {
                        COLORS = new Color[]{
                            customAreaFillTop,
                            customAreaFillBottom,
                            customAreaFillTop
                        };
                    } else {
                        COLORS = new Color[]{
                            UTIL.setAlpha(areaFill.LIGHT, 0.75f),
                            UTIL.setAlpha(areaFill.DARK, 0.0f),
                            UTIL.setAlpha(areaFill.LIGHT, 0.75f)
                        };
                    }
                    final LinearGradientPaint SPARK_LINE_GRADIENT = new LinearGradientPaint(START_POINT, END_POINT, fractions, COLORS);
                    G2.setPaint(SPARK_LINE_GRADIENT);
                    G2.fill(SPARK_LINE_FILLED);
                }
            } else {
                // Draw shadow of line which looks good on dark backgrounds
                if (lineShadowVisible) {
                    G2.translate(1, 1);
                    G2.setColor(new Color(0x000000));
                    G2.draw(SPARK_LINE);
                    G2.translate(-1, -1);
                }
            }

            // Set appropriate line color
            G2.setColor(lineColor);
            G2.draw(SPARK_LINE);

            // Draw indicators
            if (startStopIndicatorVisible) {
                G2.drawImage(startIndicatorImage, (int) pointList.get(0).getX() - startIndicatorImage.getWidth() / 2, HEIGHT - (int) pointList.get(0).getY() - startIndicatorImage.getHeight() / 2, null);
                G2.drawImage(stopIndicatorImage, (int) pointList.get(pointList.size() - 1).getX() - stopIndicatorImage.getWidth() / 2, HEIGHT - (int) pointList.get(pointList.size() - 1).getY() - stopIndicatorImage.getHeight() / 2, null);
            }
            if (hiLoIndicatorVisible) {
                if (loIndex < pointList.size()) {
                    G2.drawImage(loIndicatorImage, (int) pointList.get(loIndex).getX() - loIndicatorImage.getWidth() / 2, HEIGHT - (int) pointList.get(loIndex).getY() - loIndicatorImage.getHeight() / 2, null);
                }
                if (hiIndex < pointList.size()) {
                    G2.drawImage(hiIndicatorImage, (int) pointList.get(hiIndex).getX() - hiIndicatorImage.getWidth() / 2, HEIGHT - (int) pointList.get(hiIndex).getY() - hiIndicatorImage.getHeight() / 2, null);
                }
            }

        }
        G2.dispose();

        return IMAGE;
    }
959534
public function create($width, $height, $type = null)
    {
        if ( !is_numeric($width) ) {
            throw new \InvalidArgumentException('Image create failed, width must be numeric');
        }

        if ( !is_numeric($height) ) {
            throw new \InvalidArgumentException('Image create failed, height must be numeric');
        }

        $type = $this->getType($type);

        if ($type !== 'gif' && function_exists('imagecreatetruecolor'))
        {
            $newImage = imagecreatetruecolor($width, $height); // Unsupport gif file
        }
        else
        {
            $newImage = imagecreate($width, $height);
        }

        imagealphablending($newImage, true);

        $transparent = imagecolorallocatealpha($newImage, 255, 255, 255, 0);

        imagefilledrectangle($newImage, 0, 0, imagesx($newImage), imagesy($newImage), $transparent);
        imagefill($newImage, 0, 0, $transparent);

        imagesavealpha($newImage, true);

        $this->newImage = $newImage;

        return $this;
    }
15198
public java.awt.Graphics2D createGraphicsShapes(float width, float height) {
        return new PdfGraphics2D(this, width, height, null, true, false, 0);
    }
1136689
private BufferedImage createImage(final int WIDTH, final int HEIGHT, final int TRANSPARENCY) {
        final GraphicsConfiguration GFX_CONF = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
        if (WIDTH <= 0 || HEIGHT <= 0) {
            return GFX_CONF.createCompatibleImage(1, 1, TRANSPARENCY);
        }
        final BufferedImage IMAGE = GFX_CONF.createCompatibleImage(WIDTH, HEIGHT, TRANSPARENCY);
        return IMAGE;
    }
524066
public ImageHandlerBuilder resizeToWidth(int size) {
         if (image.getWidth() < size) return this;
         BufferedImage resize = Scalr.resize(image, Scalr.Mode.FIT_TO_WIDTH, size);
         image.flush();
         image = resize;
         return this;
     }
136313
public function create(int $width, int $height, bool $true_color = true): bool
    {
        $this->image_width = $width;
        $this->image_height = $height;

        if (!$this->haveEnoughMemoryToOpenAndProcess()) {
            throw new RuntimeException('Empty can not be created.');
        }

        if ($true_color) {
            $img = imagecreatetruecolor($width, $height);
        } else {
            $img = imagecreate($width, $height);
        }

        $this->image_resource = $img;

        return true;
    }
547350
public function canvasImageResample($width, $height)
    {
        $oCanvas = imagecreatetruecolor($width, $height);
        imagecopyresampled($oCanvas, $this->oImg, 0, 0, 0, 0, $width, $height, imagesx($this->oImg), imagesy($this->oImg));
        $this->oImg = $oCanvas;
        return $this;
    }
369114
public void setTextureSize(int width, int height) {
		setPreferredSize(new Dimension(width, height));
		setSize(new Dimension(width, height));
		this.width = width;
		this.height = height;
	}
1239199
public ImageHandlerBuilder resizeToHeight(int size) {
         if (image.getHeight() < size) return this;
         BufferedImage resize = Scalr.resize(image, Scalr.Mode.FIT_TO_HEIGHT, Math.min(size, image.getHeight()));
         image.flush();
         image = resize;
         return this;
     }
982621
public Pie radius(Object width, Object height) {
        radius = new Object[]{width, height};
        return this;
    }
1034517
protected BufferedImage create_MEASURED_VALUE_Image(final int WIDTH, final int HEIGHT, final Color COLOR) {
        if (WIDTH <= 20 || HEIGHT <= 20) // 20 is needed otherwise the image size could be smaller than 1
        {
            return UTIL.createImage(1, 1, Transparency.TRANSLUCENT);
        }

        final int IMAGE_WIDTH;
        final int IMAGE_HEIGHT;
        if (getOrientation() == Orientation.VERTICAL) {
            // Vertical orientation
            IMAGE_WIDTH = (int) (WIDTH * 0.05);
            IMAGE_HEIGHT = IMAGE_WIDTH;
        } else {
            // Horizontal orientation
            IMAGE_HEIGHT = (int) (HEIGHT * 0.05);
            IMAGE_WIDTH = IMAGE_HEIGHT;
        }

        final BufferedImage IMAGE = UTIL.createImage(IMAGE_WIDTH, IMAGE_HEIGHT, Transparency.TRANSLUCENT);
        final Graphics2D G2 = IMAGE.createGraphics();
        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        final GeneralPath INDICATOR = new GeneralPath();
        INDICATOR.setWindingRule(Path2D.WIND_EVEN_ODD);
        if (getOrientation() == Orientation.VERTICAL) {
            INDICATOR.moveTo(IMAGE_WIDTH, IMAGE_HEIGHT * 0.5);
            INDICATOR.lineTo(0.0, 0.0);
            INDICATOR.lineTo(0.0, IMAGE_HEIGHT);
            INDICATOR.closePath();
        } else {
            INDICATOR.moveTo(IMAGE_WIDTH * 0.5, 0.0);
            INDICATOR.lineTo(IMAGE_WIDTH, IMAGE_HEIGHT);
            INDICATOR.lineTo(0.0, IMAGE_HEIGHT);
            INDICATOR.closePath();
        }
        G2.setColor(COLOR);
        G2.fill(INDICATOR);

        G2.dispose();

        return IMAGE;
    }
70313
function(image, width, height) {
        var g;
        if (image.tagName === 'CANVAS' && image.width === width
                && image.height === height) {
            g = image.getContext('2d');
        } else {
            var canvas = this._newCanvas(width, height);
            canvas.width = width;
            canvas.height = height;
            g = canvas.getContext('2d');
            g.drawImage(image, 0, 0, width, height);
        }
        var data = g.getImageData(0, 0, width, height).data;
        return data;
    }
57648
public function newImage($width, $height, $background = 'white')
    {
        $this->resource->createNew($width, $height, $background);

        return $this;
    }
1329531
protected BufferedImage create_TITLE_Image(final int WIDTH, final int HEIGHT,
                                                              final boolean UNIT_STRING_VISIBLE,
                                                              BufferedImage image) {
        if (WIDTH <= 0 || HEIGHT <= 0) {
            return UTIL.createImage(1, 1, Transparency.TRANSLUCENT);
        }

        if (image == null) {
            image = UTIL.createImage(WIDTH, HEIGHT, Transparency.TRANSLUCENT);
        }
        final Graphics2D G2 = image.createGraphics();
        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        G2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
        G2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        final int IMAGE_WIDTH = image.getWidth();
        final int IMAGE_HEIGHT = image.getHeight();

        final FontRenderContext RENDER_CONTEXT = new FontRenderContext(null, true, true);

        if (isLabelColorFromThemeEnabled()) {
            G2.setColor(getBackgroundColor().LABEL_COLOR);
        } else {
            G2.setColor(getLabelColor());
        }

        final TextLayout LAYOUT_TITLE;

        if (getOrientation() == Orientation.VERTICAL) {
            // Vertical orientation
            // Draw title
            // Use custom font if selected
            if (isTitleAndUnitFontEnabled()) {
                G2.setFont(new Font(getTitleAndUnitFont().getFamily(), getTitleAndUnitFont().getStyle(), getTitleAndUnitFont().getSize()));
            } else {
                G2.setFont(new Font("Verdana", 0, (int) (0.1 * IMAGE_WIDTH)));
            }
            if (!getTitle().isEmpty()) {
                LAYOUT_TITLE = new TextLayout(getTitle(), G2.getFont(), RENDER_CONTEXT);
                final AffineTransform OLD_TRANSFORM = G2.getTransform();
                G2.translate(0.0, -0.05 * IMAGE_HEIGHT);
                G2.rotate(1.5707963267948966, 0.6714285714285714f * IMAGE_WIDTH, 0.1375f * IMAGE_HEIGHT + LAYOUT_TITLE.getAscent() - LAYOUT_TITLE.getDescent());
                G2.drawString(getTitle(), 0.6714285714285714f * IMAGE_WIDTH, 0.1375f * IMAGE_HEIGHT + LAYOUT_TITLE.getAscent() - LAYOUT_TITLE.getDescent());
                G2.setTransform(OLD_TRANSFORM);
            }
            // Draw unit string
            if (UNIT_STRING_VISIBLE && !getUnitString().isEmpty()) {
                if (isTitleAndUnitFontEnabled()) {
                    G2.setFont(new Font(getTitleAndUnitFont().getFamily(), 0, (int) (0.07142857142857142 * IMAGE_WIDTH)));
                } else {
                    G2.setFont(new Font("Verdana", 0, (int) (0.07142857142857142 * IMAGE_WIDTH)));
                }
                final TextLayout LAYOUT_UNIT = new TextLayout(getUnitString(), G2.getFont(), RENDER_CONTEXT);
                final Rectangle2D UNIT_BOUNDARY = LAYOUT_UNIT.getBounds();
                G2.drawString(getUnitString(), (float) (IMAGE_WIDTH - UNIT_BOUNDARY.getWidth()) / 2f, 0.8875f * IMAGE_HEIGHT + LAYOUT_UNIT.getAscent() - LAYOUT_UNIT.getDescent());
            }
        } else {
            // Horizontal orientation
            // Draw title
            if (isTitleAndUnitFontEnabled()) {
                G2.setFont(new Font(getTitleAndUnitFont().getFamily(), 0, (int) (0.1 * IMAGE_HEIGHT)));
            } else {
                G2.setFont(new Font("Verdana", 0, (int) (0.1 * IMAGE_HEIGHT)));
            }
            if (!getTitle().isEmpty()) {
                LAYOUT_TITLE = new TextLayout(getTitle(), G2.getFont(), RENDER_CONTEXT);
                G2.drawString(getTitle(), 0.15f * IMAGE_WIDTH, 0.25f * IMAGE_HEIGHT + LAYOUT_TITLE.getAscent() - LAYOUT_TITLE.getDescent());
            }
            // Draw unit string
            if (UNIT_STRING_VISIBLE && !getUnitString().isEmpty()) {
                if (isTitleAndUnitFontEnabled()) {
                    G2.setFont(new Font(getTitleAndUnitFont().getFamily(), 0, (int) (0.025 * IMAGE_WIDTH)));
                } else {
                    G2.setFont(new Font("Verdana", 0, (int) (0.025 * IMAGE_WIDTH)));
                }
                final TextLayout LAYOUT_UNIT = new TextLayout(getUnitString(), G2.getFont(), RENDER_CONTEXT);
                G2.drawString(getUnitString(), 0.0625f * IMAGE_WIDTH, 0.7f * IMAGE_HEIGHT + LAYOUT_UNIT.getAscent() - LAYOUT_UNIT.getDescent());
            }
        }

        G2.dispose();

        return image;
    }