コード例 #1
0
ファイル: ImageTests.cs プロジェクト: glocklueng/agg-sharp
		private bool ClearAndCheckImageFloat(ImageBufferFloat image, RGBA_Floats color)
		{
			image.NewGraphics2D().Clear(color);

			switch (image.BitDepth)
			{
				case 128:
					for (int y = 0; y < image.Height; y++)
					{
						for (int x = 0; x < image.Width; x++)
						{
							RGBA_Floats pixelColor = image.GetPixel(x, y);
							if (pixelColor != color)
							{
								return false;
							}
						}
					}
					break;

				default:
					throw new NotImplementedException();
			}

			return true;
		}
コード例 #2
0
ファイル: SimpleTests.cs プロジェクト: glocklueng/agg-sharp
		public void TestGetHashCode()
		{
			{
				RGBA_Bytes a = new RGBA_Bytes(10, 11, 12);
				RGBA_Bytes b = new RGBA_Bytes(10, 11, 12);
				Assert.IsTrue(a.GetHashCode() == b.GetHashCode());
			}
			{
				RGBA_Floats a = new RGBA_Floats(10, 11, 12);
				RGBA_Floats b = new RGBA_Floats(10, 11, 12);
				Assert.IsTrue(a.GetHashCode() == b.GetHashCode());
			}
			{
				BorderDouble a = new BorderDouble(10, 11, 12, 13);
				BorderDouble b = new BorderDouble(10, 11, 12, 13);
				Assert.IsTrue(a.GetHashCode() == b.GetHashCode());
			}
			{
				Point2D a = new Point2D(10, 11);
				Point2D b = new Point2D(10, 11);
				Assert.IsTrue(a.GetHashCode() == b.GetHashCode());
			}
			{
				RectangleDouble a = new RectangleDouble(10, 11, 12, 13);
				RectangleDouble b = new RectangleDouble(10, 11, 12, 13);
				Assert.IsTrue(a.GetHashCode() == b.GetHashCode());
			}
			{
				RectangleInt a = new RectangleInt(10, 11, 12, 13);
				RectangleInt b = new RectangleInt(10, 11, 12, 13);
				Assert.IsTrue(a.GetHashCode() == b.GetHashCode());
			}
		}
コード例 #3
0
		public static RGBA_Bytes InvertColor(RGBA_Bytes color)
		{
			RGBA_Floats colorFloat = new RGBA_Floats(color);
			double hue0To1;
			double saturation0To1;
			double lightness0To1;
			colorFloat.GetHSL(out hue0To1, out saturation0To1, out lightness0To1);
			RGBA_Floats colorInvertedFloat = RGBA_Floats.FromHSL(hue0To1, saturation0To1, 1 - lightness0To1);
			RGBA_Bytes invertedColor = new RGBA_Bytes(
				colorInvertedFloat.Red0To255,
				colorInvertedFloat.Green0To255,
				colorInvertedFloat.Blue0To255,
				// and don't change the alpha value
				color.alpha);
			return invertedColor;
		}
コード例 #4
0
		public void blend_solid_hspan(int x, int y, int len, RGBA_Floats sourceColor, byte[] covers, int coversIndex)
		{
			float colorAlpha = sourceColor.alpha;
			if (colorAlpha != 0)
			{
				unchecked
				{
					int bufferOffset;
					float[] buffer = GetPixelPointerXY(x, y, out bufferOffset);

					do
					{
						float alpha = colorAlpha * (covers[coversIndex] * (1.0f / 255.0f));
						if (alpha == 1)
						{
							m_Blender.CopyPixels(buffer, bufferOffset, sourceColor, 1);
						}
						else
						{
							m_Blender.BlendPixel(buffer, bufferOffset, new RGBA_Floats(sourceColor.red, sourceColor.green, sourceColor.blue, alpha));
						}
						bufferOffset += m_DistanceInFloatsBetweenPixelsInclusive;
						coversIndex++;
					}
					while (--len != 0);
				}
			}
		}
コード例 #5
0
		public void blend_solid_vspan(int x, int y, int len, RGBA_Floats c, byte[] covers, int coversIndex)
		{
			throw new NotImplementedException();
#if false
            if (sourceColor.m_A != 0)
            {
                int ScanWidth = StrideInBytes();
                unchecked
                {
                    byte* p = GetPixelPointerXY(x, y);
                    do
                    {
                        byte oldAlpha = sourceColor.m_A;
                        sourceColor.m_A = (byte)(((int)(sourceColor.m_A) * ((int)(*covers++) + 1)) >> 8);
                        if (sourceColor.m_A == base_mask)
                        {
                            m_Blender.CopyPixel(p, sourceColor);
                        }
                        else
                        {
                            m_Blender.BlendPixel(p, sourceColor);
                        }
                        p = &p[ScanWidth];
                        sourceColor.m_A = oldAlpha;
                    }
                    while (--len != 0);
                }
            }
#endif
		}
コード例 #6
0
ファイル: rgba.cs プロジェクト: CNCBrasil/agg-sharp
		public void BlendPixels(float[] pDestBuffer, int bufferOffset,
			RGBA_Floats[] sourceColors, int sourceColorsOffset,
			byte[] sourceCovers, int sourceCoversOffset, bool firstCoverForAll, int count)
		{
			if (firstCoverForAll)
			{
				//unsafe
				{
					if (sourceCovers[sourceCoversOffset] == 255)
					{
						for (int i = 0; i < count; i++)
						{
							BlendPixel(pDestBuffer, bufferOffset, sourceColors[sourceColorsOffset]);
							sourceColorsOffset++;
							bufferOffset += 4;
						}
					}
					else
					{
						for (int i = 0; i < count; i++)
						{
							RGBA_Floats sourceColor = sourceColors[sourceColorsOffset];
							float alpha = (sourceColor.alpha * sourceCovers[sourceCoversOffset] + 255) / 256;
							if (alpha == 0)
							{
								continue;
							}
							else if (alpha == 255)
							{
								pDestBuffer[bufferOffset + ImageBuffer.OrderR] = (byte)sourceColor.red;
								pDestBuffer[bufferOffset + ImageBuffer.OrderG] = (byte)sourceColor.green;
								pDestBuffer[bufferOffset + ImageBuffer.OrderB] = (byte)sourceColor.blue;
								pDestBuffer[bufferOffset + ImageBuffer.OrderA] = (byte)alpha;
							}
							else
							{
								float OneOverAlpha = base_mask - alpha;
								unchecked
								{
									float r = pDestBuffer[bufferOffset + ImageBuffer.OrderR] * OneOverAlpha + sourceColor.red;
									float g = pDestBuffer[bufferOffset + ImageBuffer.OrderG] * OneOverAlpha + sourceColor.green;
									float b = pDestBuffer[bufferOffset + ImageBuffer.OrderB] * OneOverAlpha + sourceColor.blue;
									float a = pDestBuffer[bufferOffset + ImageBuffer.OrderA];
									pDestBuffer[bufferOffset + ImageBuffer.OrderR] = r;
									pDestBuffer[bufferOffset + ImageBuffer.OrderG] = g;
									pDestBuffer[bufferOffset + ImageBuffer.OrderB] = b;
									pDestBuffer[bufferOffset + ImageBuffer.OrderA] = (1.0f - ((OneOverAlpha * (1.0f - a))));
								}
							}
							sourceColorsOffset++;
							bufferOffset += 4;
						}
					}
				}
			}
			else
			{
				for (int i = 0; i < count; i++)
				{
					RGBA_Floats sourceColor = sourceColors[sourceColorsOffset];
					if (sourceColor.alpha == 1 && sourceCovers[sourceCoversOffset] == 255)
					{
						pDestBuffer[bufferOffset + ImageBuffer.OrderR] = sourceColor.red;
						pDestBuffer[bufferOffset + ImageBuffer.OrderG] = sourceColor.green;
						pDestBuffer[bufferOffset + ImageBuffer.OrderB] = sourceColor.blue;
						pDestBuffer[bufferOffset + ImageBuffer.OrderA] = 1;
					}
					else
					{
						// the cover is known to be less than opaque
						float coverFloat = (sourceCovers[sourceCoversOffset] * (1.0f / 255.0f));
						float alpha = sourceColor.alpha * coverFloat;
						if (coverFloat > 0 && alpha > 0)
						{
							float OneOverAlpha = 1.0f - alpha;
							unchecked
							{
								// the color is already pre multiplied by the alpha but not by the cover value so we only need to multiply th ecolor by the cover
								float r = (pDestBuffer[bufferOffset + ImageBuffer.OrderR] * OneOverAlpha) + sourceColor.red * coverFloat;
								float g = (pDestBuffer[bufferOffset + ImageBuffer.OrderG] * OneOverAlpha) + sourceColor.green * coverFloat;
								float b = (pDestBuffer[bufferOffset + ImageBuffer.OrderB] * OneOverAlpha) + sourceColor.blue * coverFloat;

								float destAlpha = pDestBuffer[bufferOffset + ImageBuffer.OrderA];
								float a = (destAlpha + (1.0f - destAlpha) * sourceColor.alpha * coverFloat);
								pDestBuffer[bufferOffset + ImageBuffer.OrderR] = r;
								pDestBuffer[bufferOffset + ImageBuffer.OrderG] = g;
								pDestBuffer[bufferOffset + ImageBuffer.OrderB] = b;
								pDestBuffer[bufferOffset + ImageBuffer.OrderA] = a;
							}
						}
					}
					sourceColorsOffset++;
					sourceCoversOffset++;
					bufferOffset += 4;
				}
			}
		}
コード例 #7
0
ファイル: ImageProxy.cs プロジェクト: CNCBrasil/agg-sharp
		public virtual void BlendPixel(int x, int y, RGBA_Floats sourceColor, byte cover)
		{
			linkedImage.BlendPixel(x, y, sourceColor, cover);
		}
コード例 #8
0
ファイル: rgba.cs プロジェクト: CNCBrasil/agg-sharp
		public void CopyPixels(float[] buffer, int bufferOffset, RGBA_Floats[] sourceColors, int sourceColorsOffset, int count)
		{
			throw new NotImplementedException();
		}
コード例 #9
0
ファイル: rgba.cs プロジェクト: CNCBrasil/agg-sharp
		public void BlendPixel(float[] buffer, int bufferOffset, RGBA_Floats sourceColor)
		{
			if (sourceColor.alpha == 1)
			{
				buffer[bufferOffset + ImageBuffer.OrderR] = (byte)(sourceColor.red);
				buffer[bufferOffset + ImageBuffer.OrderG] = (byte)(sourceColor.green);
				buffer[bufferOffset + ImageBuffer.OrderB] = (byte)(sourceColor.blue);
				buffer[bufferOffset + ImageBuffer.OrderA] = (byte)(sourceColor.alpha);
			}
			else
			{
				float r = buffer[bufferOffset + ImageBuffer.OrderR];
				float g = buffer[bufferOffset + ImageBuffer.OrderG];
				float b = buffer[bufferOffset + ImageBuffer.OrderB];
				float a = buffer[bufferOffset + ImageBuffer.OrderA];
				buffer[bufferOffset + ImageBuffer.OrderR] = (sourceColor.red - r) * sourceColor.alpha + r;
				buffer[bufferOffset + ImageBuffer.OrderG] = (sourceColor.green - g) * sourceColor.alpha + g;
				buffer[bufferOffset + ImageBuffer.OrderB] = (sourceColor.blue - b) * sourceColor.alpha + b;
				buffer[bufferOffset + ImageBuffer.OrderA] = (sourceColor.alpha + a) - sourceColor.alpha * a;
			}
		}
コード例 #10
0
		public void blend_color_hspan(int x, int y, int len, RGBA_Floats[] colors, int colorsIndex, byte[] covers, int coversIndex, bool firstCoverForAll)
		{
			int bufferOffset = GetBufferOffsetXY(x, y);
			m_Blender.BlendPixels(m_FloatBuffer, bufferOffset, colors, colorsIndex, covers, coversIndex, firstCoverForAll, len);
		}
コード例 #11
0
		public static void BasedOnAlphaAndCover(IRecieveBlenderFloat Blender, float[] destBuffer, int bufferOffset, RGBA_Floats sourceColor, int cover)
		{
			if (cover == 255)
			{
				BasedOnAlpha(Blender, destBuffer, bufferOffset, sourceColor);
			}
			else
			{
				//if (sourceColor.m_A != 0)
				{
					sourceColor.alpha = sourceColor.alpha * ((float)cover * (1 / 255));
#if false // we blend regardless of the alpha so that we can get Light Opacity working (used this way we have additive and faster blending in one blender) LBB
                    if (sourceColor.m_A == base_mask)
                    {
                        Blender.CopyPixel(pDestBuffer, sourceColor);
                    }
                    else
#endif
					{
						Blender.BlendPixel(destBuffer, bufferOffset, sourceColor);
					}
				}
			}
		}
コード例 #12
0
ファイル: ImageProxy.cs プロジェクト: CNCBrasil/agg-sharp
		public virtual void blend_color_vspan(int x, int y, int len, RGBA_Floats[] colors, int colorsIndex, byte[] covers, int coversIndex, bool firstCoverForAll)
		{
			linkedImage.blend_color_vspan(x, y, len, colors, colorsIndex, covers, coversIndex, firstCoverForAll);
		}
コード例 #13
0
		public void copy_color_hspan(int x, int y, int len, RGBA_Floats[] colors, int colorsIndex)
		{
			int bufferOffset = GetBufferOffsetXY(x, y);

			do
			{
				m_Blender.CopyPixels(m_FloatBuffer, bufferOffset, colors[colorsIndex], 1);

				++colorsIndex;
				bufferOffset += m_DistanceInFloatsBetweenPixelsInclusive;
			}
			while (--len != 0);
		}
コード例 #14
0
ファイル: ImageProxy.cs プロジェクト: CNCBrasil/agg-sharp
		public virtual void blend_solid_vspan(int x, int y, int len, RGBA_Floats c, byte[] covers, int coversIndex)
		{
			linkedImage.blend_solid_vspan(x, y, len, c, covers, coversIndex);
		}
コード例 #15
0
ファイル: ImageProxy.cs プロジェクト: CNCBrasil/agg-sharp
		public virtual void copy_color_vspan(int x, int y, int len, RGBA_Floats[] colors, int colorIndex)
		{
			linkedImage.copy_color_vspan(x, y, len, colors, colorIndex);
		}
コード例 #16
0
ファイル: ImageProxy.cs プロジェクト: CNCBrasil/agg-sharp
		public virtual void blend_vline(int x, int y1, int y2, RGBA_Floats sourceColor, byte cover)
		{
			linkedImage.blend_vline(x, y1, y2, sourceColor, cover);
		}
コード例 #17
0
ファイル: ImageProxy.cs プロジェクト: CNCBrasil/agg-sharp
		public virtual void blend_hline(int x1, int y, int x2, RGBA_Floats sourceColor, byte cover)
		{
			linkedImage.blend_hline(x1, y, x2, sourceColor, cover);
		}
コード例 #18
0
ファイル: ImageProxy.cs プロジェクト: CNCBrasil/agg-sharp
		public virtual void copy_vline(int x, int y, int len, RGBA_Floats sourceColor)
		{
			linkedImage.copy_vline(x, y, len, sourceColor);
		}
コード例 #19
0
		public void copy_color_vspan(int x, int y, int len, RGBA_Floats[] colors, int colorsIndex)
		{
			int bufferOffset = GetBufferOffsetXY(x, y);

			do
			{
				m_Blender.CopyPixels(m_FloatBuffer, bufferOffset, colors[colorsIndex], 1);

				++colorsIndex;
				bufferOffset += m_StrideInFloats;
			}
			while (--len != 0);
		}
コード例 #20
0
		public virtual void SetPixel(int x, int y, RGBA_Floats color)
		{
			x -= (int)m_OriginOffset.x;
			y -= (int)m_OriginOffset.y;
			m_Blender.CopyPixels(GetBuffer(), GetBufferOffsetXY(x, y), color, 1);
		}
コード例 #21
0
		public void blend_color_vspan(int x, int y, int len, RGBA_Floats[] colors, int colorsIndex, byte[] covers, int coversIndex, bool firstCoverForAll)
		{
			int bufferOffset = GetBufferOffsetXY(x, y);

			int ScanWidth = StrideInFloatsAbs();
			if (!firstCoverForAll)
			{
				do
				{
					DoCopyOrBlendFloat.BasedOnAlphaAndCover(m_Blender, m_FloatBuffer, bufferOffset, colors[colorsIndex], covers[coversIndex++]);
					bufferOffset += ScanWidth;
					++colorsIndex;
				}
				while (--len != 0);
			}
			else
			{
				if (covers[coversIndex] == 1)
				{
					do
					{
						DoCopyOrBlendFloat.BasedOnAlpha(m_Blender, m_FloatBuffer, bufferOffset, colors[colorsIndex]);
						bufferOffset += ScanWidth;
						++colorsIndex;
					}
					while (--len != 0);
				}
				else
				{
					do
					{
						DoCopyOrBlendFloat.BasedOnAlphaAndCover(m_Blender, m_FloatBuffer, bufferOffset, colors[colorsIndex], covers[coversIndex]);
						bufferOffset += ScanWidth;
						++colorsIndex;
					}
					while (--len != 0);
				}
			}
		}
コード例 #22
0
		public void BlendPixel(int x, int y, RGBA_Floats c, byte cover)
		{
			throw new System.NotImplementedException();
			/*
			cob_type::copy_or_blend_pix(
				(value_type*)m_rbuf->row_ptr(x, y, 1)  + x + x + x,
				c.r, c.g, c.b, c.a,
				cover);*/
		}
コード例 #23
0
ファイル: rgba.cs プロジェクト: CNCBrasil/agg-sharp
		public void BlendPixels(float[] destBuffer, int bufferOffset,
			RGBA_Floats[] sourceColors, int sourceColorsOffset,
			byte[] covers, int coversIndex, bool firstCoverForAll, int count)
		{
			throw new NotImplementedException();
		}
コード例 #24
0
		public void copy_hline(int x, int y, int len, RGBA_Floats sourceColor)
		{
			int bufferOffset;
			float[] buffer = GetPixelPointerXY(x, y, out bufferOffset);

			m_Blender.CopyPixels(buffer, bufferOffset, sourceColor, len);
		}
コード例 #25
0
ファイル: rgba.cs プロジェクト: CNCBrasil/agg-sharp
		public void CopyPixels(float[] buffer, int bufferOffset, RGBA_Floats sourceColor, int count)
		{
			do
			{
				buffer[bufferOffset + ImageBuffer.OrderR] = sourceColor.red;
				buffer[bufferOffset + ImageBuffer.OrderG] = sourceColor.green;
				buffer[bufferOffset + ImageBuffer.OrderB] = sourceColor.blue;
				buffer[bufferOffset + ImageBuffer.OrderA] = sourceColor.alpha;
				bufferOffset += 4;
			}
			while (--count != 0);
		}
コード例 #26
0
		public void copy_vline(int x, int y, int len, RGBA_Floats sourceColor)
		{
			throw new NotImplementedException();
#if false
            int scanWidth = StrideInBytes();
            byte* pDestBuffer = GetPixelPointerXY(x, y);
            do
            {
                m_Blender.CopyPixel(pDestBuffer, sourceColor);
                pDestBuffer = &pDestBuffer[scanWidth];
            }
            while (--len != 0);
#endif
		}
コード例 #27
0
ファイル: rgba.cs プロジェクト: CNCBrasil/agg-sharp
		public void BlendPixels(float[] pDestBuffer, int bufferOffset,
			RGBA_Floats[] sourceColors, int sourceColorsOffset,
			byte[] sourceCovers, int sourceCoversOffset, int count)
		{
		}
コード例 #28
0
		public void blend_hline(int x1, int y, int x2, RGBA_Floats sourceColor, byte cover)
		{
			if (sourceColor.alpha != 0)
			{
				int len = x2 - x1 + 1;

				int bufferOffset;
				float[] buffer = GetPixelPointerXY(x1, y, out bufferOffset);

				float alpha = sourceColor.alpha * (cover * (1.0f / 255.0f));
				if (alpha == 1)
				{
					m_Blender.CopyPixels(buffer, bufferOffset, sourceColor, len);
				}
				else
				{
					do
					{
						m_Blender.BlendPixel(buffer, bufferOffset, new RGBA_Floats(sourceColor.red, sourceColor.green, sourceColor.blue, alpha));
						bufferOffset += m_DistanceInFloatsBetweenPixelsInclusive;
					}
					while (--len != 0);
				}
			}
		}
コード例 #29
0
ファイル: agg_color_gray.cs プロジェクト: jeske/agg-sharp
 //--------------------------------------------------------------------
 public gray8(RGBA_Floats c, double a_)
 {
     v=((byte)agg_basics.uround((0.299*c.Red0To255 + 0.587*c.Green0To255 + 0.114*c.Blue0To255) * (double)(base_mask)));
     a=((byte)agg_basics.uround(a_ * (double)(base_mask)));
 }
コード例 #30
0
		public void blend_vline(int x, int y1, int y2, RGBA_Floats sourceColor, byte cover)
		{
			throw new NotImplementedException();
#if false
            int ScanWidth = StrideInBytes();
            if (sourceColor.m_A != 0)
            {
                unsafe
                {
                    int len = y2 - y1 + 1;
                    byte* p = GetPixelPointerXY(x, y1);
                    sourceColor.m_A = (byte)(((int)(sourceColor.m_A) * (cover + 1)) >> 8);
                    if (sourceColor.m_A == base_mask)
                    {
                        byte cr = sourceColor.m_R;
                        byte cg = sourceColor.m_G;
                        byte cb = sourceColor.m_B;
                        do
                        {
                            m_Blender.CopyPixel(p, sourceColor);
                            p = &p[ScanWidth];
                        }
                        while (--len != 0);
                    }
                    else
                    {
                        if (cover == 255)
                        {
                            do
                            {
                                m_Blender.BlendPixel(p, sourceColor);
                                p = &p[ScanWidth];
                            }
                            while (--len != 0);
                        }
                        else
                        {
                            do
                            {
                                m_Blender.BlendPixel(p, sourceColor);
                                p = &p[ScanWidth];
                            }
                            while (--len != 0);
                        }
                    }
                }
            }
#endif
		}