public uint num_edges() { return(m_edges.Size()); }
public void rotate_colors() { uint i; for (i = 1; i < m_vertices.Size(); i++) { RGBA_Bytes c = m_vertices[i].color; RGBA_Bytes dc = m_vertices[i].dc; int r = (int)c.R_Byte + (dc.R_Byte != 0 ? 5 : -5); int g = (int)c.G_Byte + (dc.G_Byte != 0 ? 5 : -5); int b = (int)c.B_Byte + (dc.B_Byte != 0 ? 5 : -5); uint dcr = dc.R_Byte, dcg = dc.G_Byte, dcb = dc.B_Byte, dca = dc.A_Byte; if (r < 0) { r = 0; dcr = dc.R_Byte ^ 1; } if (r > 255) { r = 255; dcr = dc.R_Byte ^ 1; } if (g < 0) { g = 0; dcg = dc.G_Byte ^ 1; } if (g > 255) { g = 255; dcg = dc.G_Byte ^ 1; } if (b < 0) { b = 0; dcb = dc.B_Byte ^ 1; } if (b > 255) { b = 255; dcb = dc.B_Byte ^ 1; } dc = new RGBA_Bytes(dcr, dcg, dcb, dca); //if (r < 0) //{ // r = 0; // dc.R_Byte ^= 1; //} //if (r > 255) //{ // r = 255; // dc.R_Byte ^= 1; //} //if (g < 0) //{ // g = 0; // dc.G_Byte ^= 1; //} //if (g > 255) //{ // g = 255; // dc.G_Byte ^= 1; //} //if (b < 0) //{ // b = 0; // dc.B_Byte ^= 1; //} //if (b > 255) //{ // b = 255; // dc.B_Byte ^= 1; //} //c.R_Byte = (uint)r; //c.G_Byte = (uint)g; //c.B_Byte = (uint)b; c = new RGBA_Bytes((uint)r, (uint)g, (uint)b, c.A_Byte); } }
public uint num_triangles() { return(m_triangles.Size()); }
public void BlurX(IPixelFormat img, double radius) { if (radius < 0.62) { return; } if (img.Width < 3) { return; } double s = (double)(radius * 0.5); double q = (double)((s < 2.5) ? 3.97156 - 4.14554 * Math.Sqrt(1 - 0.26891 * s) : 0.98711 * s - 0.96330); double q2 = (double)(q * q); double q3 = (double)(q2 * q); double b0 = (double)(1.0 / (1.578250 + 2.444130 * q + 1.428100 * q2 + 0.422205 * q3)); double b1 = (double)(2.44413 * q + 2.85619 * q2 + 1.26661 * q3); double b2 = (double)(-1.42810 * q2 + -1.26661 * q3); double b3 = (double)(0.422205 * q3); double b = (double)(1 - (b1 + b2 + b3) * b0); b1 *= b0; b2 *= b0; b3 *= b0; uint w = img.Width; uint h = img.Height; int wm = (int)w - 1; int x, y; int StartCreatingAt = (int)m_sum1.Size(); m_sum1.Resize(w); m_sum2.Resize(w); m_buf.Allocate(w); RecursizeBlurCalculator[] Sum1Array = m_sum1.Array; RecursizeBlurCalculator[] Sum2Array = m_sum2.Array; RGBA_Bytes[] BufferArray = m_buf.Array; for (int i = StartCreatingAt; i < w; i++) { Sum1Array[i] = m_RecursizeBlurCalculatorFactory.CreateNew(); Sum2Array[i] = m_RecursizeBlurCalculatorFactory.CreateNew(); } for (y = 0; y < h; y++) { RecursizeBlurCalculator c = m_RecursizeBlurCalculatorFactory; c.FromPix(img.Pixel(0, y)); Sum1Array[0].Calc(b, b1, b2, b3, c, c, c, c); c.FromPix(img.Pixel(1, y)); Sum1Array[1].Calc(b, b1, b2, b3, c, Sum1Array[0], Sum1Array[0], Sum1Array[0]); c.FromPix(img.Pixel(2, y)); Sum1Array[2].Calc(b, b1, b2, b3, c, Sum1Array[1], Sum1Array[0], Sum1Array[0]); for (x = 3; x < w; ++x) { c.FromPix(img.Pixel(x, y)); Sum1Array[x].Calc(b, b1, b2, b3, c, Sum1Array[x - 1], Sum1Array[x - 2], Sum1Array[x - 3]); } Sum2Array[wm].Calc(b, b1, b2, b3, Sum1Array[wm], Sum1Array[wm], Sum1Array[wm], Sum1Array[wm]); Sum2Array[wm - 1].Calc(b, b1, b2, b3, Sum1Array[wm - 1], Sum2Array[wm], Sum2Array[wm], Sum2Array[wm]); Sum2Array[wm - 2].Calc(b, b1, b2, b3, Sum1Array[wm - 2], Sum2Array[wm - 1], Sum2Array[wm], Sum2Array[wm]); Sum2Array[wm].ToPix(ref BufferArray[wm]); Sum2Array[wm - 1].ToPix(ref BufferArray[wm - 1]); Sum2Array[wm - 2].ToPix(ref BufferArray[wm - 2]); for (x = wm - 3; x >= 0; --x) { Sum2Array[x].Calc(b, b1, b2, b3, Sum1Array[x], Sum2Array[x + 1], Sum2Array[x + 2], Sum2Array[x + 3]); Sum2Array[x].ToPix(ref BufferArray[x]); } unsafe { fixed(RGBA_Bytes *pBuffer = BufferArray) { img.CopyColorHSpan(0, y, w, pBuffer); } } } }