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 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 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 paint(Graphics g) { g.setColor(0xFFFFFF); g.fillRect(0, 0, getWidth(), getHeight()); if (image != null) { g.drawImage(image, getWidth() / 2, getHeight() / 2, Graphics.VCENTER | Graphics.HCENTER); } g.setColor(0x000000); for (int i = 0; i < log.Length; i++) { if (log[i] != null) { g.drawString(log[i], 0, i * logFont.getHeight(), Graphics.TOP | Graphics.LEFT); } } }
public virtual void paint(javax.microedition.lcdui.Graphics g) { setparam(); if (width < 100 || height < 100) { return; } drawGraph(g); if (pointerMode != PMODE_POINT) { drawStraightLine(g); } if (pointerMode != PMODE_LINE && xp >= 0) { drawPointer(g); } g.drawImage(ShowLine, width - xright + 3, ytop, g.LEFT | g.TOP); }
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); }