public static javax.microedition.lcdui.Image createImage(javax.microedition.lcdui.Image image, int x, int y, int width, int height) { Image ret = Image.createImage(width, height); ret.getGraphics().drawImageRegion(image, 0, 0, x, y, width, height, 0); return(ret); }
public Image subImage(int x, int y, int w, int h) { if (x >= 0 && (x + w) <= getWidth() && y >= 0 && (y + h) <= getHeight()) { Image buff = createImage(w, h); Graphics bg = buff.getGraphics(); bg.drawImage(this, -x, -y); return(buff); } return(null); }
public virtual void drawLine(Line line, int color) { Image bufImage = Image.createImage(image.getWidth(), image.getHeight()); Graphics g = bufImage.getGraphics(); g.drawImage(image, 0, 0, 0); g.setColor(color); g.drawLine(line.getP1().getX(), line.getP1().getY(), line.getP2().getX(), line.getP2().getY()); image = bufImage; repaint(); }
public virtual void drawCross(Point point, int color) { Image bufImage = Image.createImage(image.getWidth(), image.getHeight()); Graphics g = bufImage.getGraphics(); g.drawImage(image, 0, 0, 0); g.setColor(color); g.drawLine(point.getX() - 5, point.getY(), point.getX() + 5, point.getY()); g.drawLine(point.getX(), point.getY() - 5, point.getX(), point.getY() + 5); image = bufImage; repaint(); }
public virtual void drawPoints(Point[] points, int color) { Image bufImage = Image.createImage(image.getWidth(), image.getHeight()); Graphics g = bufImage.getGraphics(); g.drawImage(image, 0, 0, 0); g.setColor(color); for (int i = 0; i < points.length - 1; i++) { g.drawLine(points[i].getX(), points[i].getY(), points[i].getX() + 1, points[i].getY()); } image = bufImage; repaint(); }
public virtual void drawLines(Line[] lines, int color) { Image bufImage = Image.createImage(image.getWidth(), image.getHeight()); Graphics g = bufImage.getGraphics(); g.drawImage(image, 0, 0, 0); g.setColor(color); for (int i = 0; i < lines.length - 1; i++) { g.drawLine(lines[i].getP1().getX(), lines[i].getP1().getY(), lines[i].getP2().getX(), lines[i].getP2().getY()); } image = bufImage; repaint(); }
public virtual void drawMatrix(bool[][] matrix) { Image bufImage = Image.createImage(image.getWidth(), image.getHeight()); Graphics g = bufImage.getGraphics(); g.setColor(0xCCCCCC); for (int y = 0; y < matrix[0].Length; y++) { for (int x = 0; x < matrix.Length; x++) { if (matrix[x][y] == true) { g.drawLine(x, y, x + 1, y); } } } image = bufImage; repaint(); }
public void flipSelf(int transform) { int width = getWidth(); int height = getHeight(); switch (Graphics.FlipTable[transform]) { case System.Drawing.RotateFlipType.Rotate90FlipNone: //1 case System.Drawing.RotateFlipType.Rotate270FlipNone: //3 case System.Drawing.RotateFlipType.Rotate90FlipX: //5 case System.Drawing.RotateFlipType.Rotate270FlipX: //7 width = getHeight(); height = getWidth(); break; } Image dst = createImage(width, height); Graphics g = dst.getGraphics(); g.drawImageTrans(this, 0, 0, transform); _dimg = dst.dimg; }
public System.Drawing.Rectangle cutTransparentImageSize(int broadPixel) { System.Drawing.Bitmap image = asBitmap(); System.Drawing.Rectangle ret = new System.Drawing.Rectangle(); int left = 0; int right = image.Width - 1; int top = 0; int bottom = image.Height - 1; int x = 0; int y = 0; System.Drawing.Color c; #region findTBLR bool finded = false; // find left for (x = 0; x < image.Width; x++) { for (y = image.Height - 1; y >= 0; --y) { c = image.GetPixel(x, y); if (c.A != 0) { left = x; finded = true; break; } } if (finded) { break; } } finded = false; // right for (x = image.Width - 1; x >= 0; --x) { for (y = image.Height - 1; y >= 0; --y) { c = image.GetPixel(x, y); if (c.A != 0) { right = x; finded = true; break; } } if (finded) { break; } } finded = false; // top for (y = 0; y < image.Height; y++) { for (x = image.Width - 1; x >= 0; --x) { c = image.GetPixel(x, y); if (c.A != 0) { top = y; finded = true; break; } } if (finded) { break; } } finded = false; // bottom for (y = image.Height - 1; y >= 0; --y) { for (x = image.Width - 1; x >= 0; --x) { c = image.GetPixel(x, y); if (c.A != 0) { bottom = y; finded = true; break; } } if (finded) { break; } } #endregion left = Math.Max(0, left - broadPixel); right = Math.Min(image.Width - 1, right + broadPixel); top = Math.Max(0, top - broadPixel); bottom = Math.Min(image.Height - 1, bottom + broadPixel); ret.X = left; ret.Y = top; ret.Width = right - left + 1; ret.Height = bottom - top + 1; Image dst = createImage(ret.Width, ret.Height); Graphics dstg = dst.getGraphics(); dstg.drawImage(this, -left, -top); _dimg = dst.dimg; dst = null; return(ret); }