Exemplo n.º 1
0
        private void DrawImage(LGraphics pixel, int x, int y, int w, int h,
                int offsetX, int offsetY)
        {
            if (isClose)
            {
                return;
            }
            pixel.UpdatePixels();

            x += translateX;
            y += translateY;

            Color[] currentPixels = pixel.pixels;
            uint transparent = pixel.transparent;
            if (x < 0)
            {
                w += x;
                offsetX -= x;
                x = 0;
            }
            if (y < 0)
            {
                h += y;
                offsetY -= y;
                y = 0;
            }
            if (x + w > width)
            {
                w = width - x;
            }
            if (y + h > height)
            {
                h = height - y;
            }
            if (w < 0 || h < 0)
            {
                return;
            }
            if (transparent < 0)
            {
                for (int size = 0; size < h; size++)
                {
                    Array.Copy(currentPixels, (offsetY + size) * pixel.width
                            + offsetX, pixels, (y + size) * width + x, w);
                }
            }
            else
            {
                int findIndex = y * width + x;
                int drawIndex = offsetY * pixel.width + offsetX;
                int moveFind = width - w;
                int moveDraw = pixel.width - w;
                for (int i = 0; i < h; i++)
                {
                    for (int j = 0; j < w; )
                    {
                        if (Inside(j, i))
                        {
                            continue;
                        }
                        if (currentPixels[drawIndex].PackedValue != transparent)
                        {
                            DrawPoint(pixels, findIndex,
                                    currentPixels[drawIndex].PackedValue);
                        }
                        j++;
                        findIndex++;
                        drawIndex++;
                    }
                    findIndex += moveFind;
                    drawIndex += moveDraw;
                }
            }
        }
Exemplo n.º 2
0
 public FillArc_CircleUpdate(LGraphics bit, int[] xs, int[] ys, int n, RectBox b)
 {
     this.pixmap = bit;
     xPoints = xs;
     yPoints = ys;
     nPoints = n;
     bounds = b;
 }
Exemplo n.º 3
0
 public void Interleave(LGraphics pix, int[][] mask)
 {
     pix.UpdatePixels();
     Color[] processedPixels = new Color[size];
     int m = mask.Length, n = mask[0].Length;
     int i = 0, j = 0;
     for (int y = 0; y < height; ++y)
     {
         int yOffset = y * width;
         for (int x = 0; x < width; ++x)
         {
             int offset = x + yOffset;
             processedPixels[offset] = (mask[i][j] == 1) ? pixels[offset]
                     : pix.pixels[offset];
             if (++j >= n)
             {
                 j = 0;
             }
         }
         if (++i >= m)
         {
             i = 0;
         }
     }
     this.pixels = processedPixels;
     this.isDitry = true;
 }
Exemplo n.º 4
0
 public FillOval_CircleUpdate(LGraphics bit)
 {
     this.pixmap = bit;
 }
Exemplo n.º 5
0
 public LGraphics GetLGraphics()
 {
     if (this.bMutable)
     {
         if (m_g == null || m_g.IsClose())
         {
             m_g = new LGraphics(this);
             isUpdate = true;
         }
         return m_g;
     }
     return null;
 }
Exemplo n.º 6
0
 public static void CopyArea(LImage image, LGraphics g, int x, int y, int width, int height, int dx, int dy)
 {
     LImage tmp = image.GetSubImage(x, y, width, height);
     g.DrawImage(tmp, x + dx, y + dy);
     tmp.Dispose();
     tmp = null;
 }
Exemplo n.º 7
0
		public void DrawHeight(LGraphics g, int x, int y) {
			try {
				if (drawImgHeight == null) {
					drawImgHeight = LImage.CreateImage(width, height, true);
					LGraphics gl = drawImgHeight.GetLGraphics();
					for (int i = 0; i < height; i++) {
						gl.SetColor(
								(start.GetRed() * (height - i)) / height
										+ (end.GetRed() * i) / height,
								(start.GetGreen() * (height - i)) / height
										+ (end.GetGreen() * i) / height,
								(start.GetBlue() * (height - i)) / height
										+ (end.GetBlue() * i) / height, alpha);
						gl.DrawLine(0, i, width, i);
					}
					gl.Dispose();
					gl = null;
				}
				g.DrawImage(drawImgHeight, x, y);
			} catch (Exception) {
				for (int i = 0; i < height; i++) {
					g.SetColor(
							(start.GetRed() * (height - i)) / height
									+ (end.GetRed() * i) / height,
							(start.GetGreen() * (height - i)) / height
									+ (end.GetGreen() * i) / height,
							(start.GetBlue() * (height - i)) / height
									+ (end.GetBlue() * i) / height, alpha);
					g.DrawLine(x, i + y, x + width, i + y);
				}
			}
		}
Exemplo n.º 8
0
		public void DrawWidth(LGraphics g, int x, int y) {
			try {
				if (drawImgWidth == null) {
					drawImgWidth = LImage.CreateImage(width, height, true);
					LGraphics gl = drawImgWidth.GetLGraphics();
					for (int i = 0; i < width; i++) {
						gl.SetColor(
								(start.GetRed() * (width - i)) / width
										+ (end.GetRed() * i) / width,
								(start.GetGreen() * (width - i)) / width
										+ (end.GetGreen() * i) / width,
								(start.GetBlue() * (width - i)) / width
										+ (end.GetBlue() * i) / width, alpha);
						gl.DrawLine(i, 0, i, height);
					}
					gl.Dispose();
					gl = null;
				}
				g.DrawImage(drawImgWidth, x, y);
			} catch (Exception) {
				for (int i = 0; i < width; i++) {
					g.SetColor(
							(start.GetRed() * (width - i)) / width
									+ (end.GetRed() * i) / width,
							(start.GetGreen() * (width - i)) / width
									+ (end.GetGreen() * i) / width,
							(start.GetBlue() * (width - i)) / width
									+ (end.GetBlue() * i) / width, alpha);
					g.DrawLine(i + x, y, i + x, y + height);
				}
			}
		}