public void LoadFromBitmap(Bitmap bmp) { if (bmp.Width != Width || bmp.Height != Height) { throw new ArgumentException("Size missmatch"); } unsafe { BitmapData bmpData = null; try { bmpData = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); for (int y = 0; y < bmpData.Height; y++) { uint *p = (uint *)((byte *)bmpData.Scan0 + y * bmpData.Stride); for (int x = 0; x < bmpData.Width; x++) { this[x, y] = RawColor.FromARGB(*p); p++; } } } finally { if (bmpData != null) { bmp.UnlockBits(bmpData); } } } }
public override void FillRectangle(Chaos.Image.RawColor color, Chaos.Util.Mathematics.RectangleF rect) { using (System.Drawing.Brush brush2 = CreateBrush(color)) { InternalGraphics.FillRectangle(brush2, rect.Convert()); } }
public override void DrawString(string text, CommonGui.Drawing.Font font, Chaos.Image.RawColor color, Vector2f position) { using (System.Drawing.Font font2 = CreateFont(font)) { using (System.Drawing.Brush brush = CreateBrush(color)) { InternalGraphics.DrawString(text, font2, brush, new System.Drawing.PointF(position.X, position.Y)); } } }
public RawColor this[int x, int y] { get { return(RawColor.FromARGB(mData[start + x + width * y])); } set { mData[x + width * y] = (int)value.ARGB; } }
public static RawColor[] GetColumn(this Pixels pix, int x) { RawColor[] col = new RawColor[pix.Height]; int i = x; for (int y = 0; y < col.Length; y++) { col[y] = pix[x, y]; i += pix.Width; } return(col); }
public static RawColor[] GetRow(this Pixels pix, int y) { RawColor[] row = new RawColor[pix.Width]; int i = pix.Width * y; for (int x = 0; x < row.Length; x++) { row[x] = pix[x, y]; i++; } return(row); }
public static RawColor[] GetLine(this Pixels pix, Point p1, Point p2) { int width = p2.X - p1.X; int height = p2.Y - p1.Y; int longSide = Math.Max(Math.Abs(width), Math.Abs(height)); double dx = (double)width / longSide; double dy = (double)height / longSide; RawColor[] result = new RawColor[longSide + 1]; for (int i = 0; i < longSide + 1; i++) { result[i] = pix[(int)Math.Round(p1.X + dx * i), (int)Math.Round(p2.Y + dy * i)]; } return(result); }