Esempio n. 1
0
        public void display_pmap(Graphics displayGraphics, RasterBuffer src)
        {
            if (m_sys_format == m_format)
            {
                m_pmap_window.Draw(displayGraphics);
            }
            else
            {
                PixelMap pmap_tmp = new PixelMap();
                pmap_tmp.Create(m_pmap_window.Width(),
                                m_pmap_window.Height(), PlatformSupportAbstract.GetBitDepthForPixelFormat(m_sys_format));

                RasterBuffer rbuf_tmp = new RasterBuffer();
                unsafe
                {
                    rbuf_tmp.Attach(pmap_tmp.buf(),
                                    pmap_tmp.Width(),
                                    pmap_tmp.Height(),
                                    m_app.FlipY() ?
                                    pmap_tmp.stride() :
                                    -pmap_tmp.stride(), pmap_tmp.bpp());
                }

                convert_pmap(rbuf_tmp, src, m_format);
                pmap_tmp.Draw(displayGraphics);

                throw new System.NotImplementedException();
            }
        }
Esempio n. 2
0
 //--------------------------------------------------------------------
 //--------------------------------------------------------------------
 public FormatGray(RasterBuffer rb, IBlenderGray blender, uint step, uint offset)
 {
     m_rbuf   = rb;
     Blender  = blender;
     m_Step   = step;
     m_Offset = offset;
 }
Esempio n. 3
0
        public static void CreateContext(RasterBuffer renderingBuffer)
        {
            // set the rendering buffer and all the GL default states (this is also where you can new anything you need)
            s_RenderingBuffer = renderingBuffer;
            s_Rasterizer.SetVectorClipBox(M.Zero <T>(), M.Zero <T>(), M.New <T>(s_RenderingBuffer.Width), M.New <T>(s_RenderingBuffer.Height));
            s_PixelFormt = new FormatRGBA(s_RenderingBuffer, new BlenderBGRA());
            s_ClippingPixelFormatProxy = new FormatClippingProxy(s_PixelFormt);
            //s_ClippingPixelFormatProxy = s_PixelFormt;

            m_CurAccumulatedMatrix = MatrixFactory <T> .NewIdentity(VectorDimension.Three); // new Matrix4X4();

            m_ModelviewMatrix = MatrixFactory <T> .NewIdentity(VectorDimension.Three);      // new Matrix4X4();

            m_ProjectionMatrix = MatrixFactory <T> .NewIdentity(VectorDimension.Three);     //new Matrix4X4();

            m_pVertexCache = new VertexCachItem[m_MaxVertexCacheItems];
            for (int i = 0; i < m_MaxVertexCacheItems; i++)
            {
                m_pVertexCache[i] = new VertexCachItem();
            }

            m_LastSetColor  = new RGBA_Doubles(1, 1, 1, 1);
            m_LastSetNormal = MatrixFactory <T> .CreateZeroVector(VectorDimension.Three);          // new Vector3D();

            m_LastSetTextureCoordinate = MatrixFactory <T> .CreateZeroVector(VectorDimension.Two); // new Vector2D();
        }
        public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len)
        {
            RasterBuffer          pSourceRenderingBuffer = base.Source().PixelFormat.GetRenderingBuffer();
            ISpanInterpolator <T> spanInterpolator       = base.Interpolator;

            spanInterpolator.Begin(M.New <T>(x).Add(base.FilterDxDbl()), M.New <T>(y).Add(base.FilterDyDbl()), len);
            do
            {
                int x_hr;
                int y_hr;
                spanInterpolator.Coordinates(out x_hr, out y_hr);
                int   x_lr   = x_hr >> (int)image_subpixel_scale_e.Shift;
                int   y_lr   = y_hr >> (int)image_subpixel_scale_e.Shift;
                byte *fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);
                //byte* fg_ptr = spanInterpolator.span(x_lr, y_lr, 1);


                //(*span).R = fg_ptr[OrderR];
                //(*span).G = fg_ptr[OrderG];
                //(*span).B = fg_ptr[OrderB];
                //(*span).A = fg_ptr[OrderA];


                (*span) = new RGBA_Bytes(fg_ptr[OrderR], fg_ptr[OrderG], fg_ptr[OrderB], fg_ptr[OrderA]);

                ++span;
                spanInterpolator.Next();
            } while (--len != 0);
        }
Esempio n. 5
0
        protected override void DoDraw(RendererBase <T> destRenderer)
        {
            Image <T> imageToDraw = ImageSequenceReference.Instance.GetImageByTime(m_TotalSeconds);
            //Image imageToDraw = m_PlayerShipSequence.GetImageByIndex(m_ImageIndex);
            //IBlender blender = new BlenderBGRA();
            IBlender blender = new BlenderAddativeBGR();

            unsafe
            {
                RasterBuffer destBuffer   = destRenderer.PixelFormat.GetRenderingBuffer();
                byte *       pPixels      = destBuffer.GetPixelPointer(200);
                byte[]       sourceBuffer = imageToDraw.ImageBuffer;
                for (int y = 0; y < imageToDraw.Height; y++)
                {
                    int SourceYOffset = y * imageToDraw.ScanWidthInBytes;
                    int destYOffset   = (int)destBuffer.StrideInBytesAbs * y;
                    for (int x = 0; x < imageToDraw.Width; x++)
                    {
                        int sourceOffset = SourceYOffset + x * 4;
                        blender.BlendPix(&pPixels[destYOffset + x * 4],
                                         sourceBuffer[sourceOffset + 2], sourceBuffer[sourceOffset + 1], sourceBuffer[sourceOffset + 0], sourceBuffer[sourceOffset + 3]);
                    }
                }
            }
        }
Esempio n. 6
0
 public void CopyFrom(RasterBuffer sourceBuffer, int xdst, int ydst, int xsrc, int ysrc, uint len)
 {
     unsafe
     {
         Basics.memmove(&_rasterBuffer.GetPixelPointer(ydst)[xdst * 3],
                        &sourceBuffer.GetPixelPointer(ysrc)[xsrc * 3],
                        (int)len * 3);
     }
 }
Esempio n. 7
0
        public unsafe void PixelHighRes(RasterBuffer buf, RGBA_Bytes *p, int x, int y)
        {
            int r, g, b, a;

            r = g = b = a = LineAABasics.LineSubPixelScale * LineAABasics.LineSubPixelScale / 2;

            int weight;
            int x_lr = x >> LineAABasics.LineSubPixelShift;
            int y_lr = y >> LineAABasics.LineSubPixelShift;

            x &= LineAABasics.LineSubPixelMask;
            y &= LineAABasics.LineSubPixelMask;
            RGBA_Bytes *ptr = (RGBA_Bytes *)buf.GetPixelPointer(x_lr, y_lr);

            weight = (LineAABasics.LineSubPixelScale - x) *
                     (LineAABasics.LineSubPixelScale - y);
            r += weight * ptr->R;
            g += weight * ptr->G;
            b += weight * ptr->B;
            a += weight * ptr->A;

            ++ptr;

            weight = x * (LineAABasics.LineSubPixelScale - y);
            r     += weight * ptr->R;
            g     += weight * ptr->G;
            b     += weight * ptr->B;
            a     += weight * ptr->A;

            ptr = (RGBA_Bytes *)buf.GetPixelPointer(x_lr, y_lr + 1);

            weight = (LineAABasics.LineSubPixelScale - x) * y;
            r     += weight * ptr->R;
            g     += weight * ptr->G;
            b     += weight * ptr->B;
            a     += weight * ptr->A;

            ++ptr;

            weight = x * y;
            r     += weight * ptr->R;
            g     += weight * ptr->G;
            b     += weight * ptr->B;
            a     += weight * ptr->A;

            //p->R = (byte)(r >> LineAABasics.LineSubPixelShift * 2);
            //p->G = (byte)(g >> LineAABasics.LineSubPixelShift * 2);
            //p->B = (byte)(b >> LineAABasics.LineSubPixelShift * 2);
            //p->A = (byte)(a >> LineAABasics.LineSubPixelShift * 2);

            (*p) = new RGBA_Bytes(
                (byte)(r >> LineAABasics.LineSubPixelShift * 2),
                (byte)(g >> LineAABasics.LineSubPixelShift * 2),
                (byte)(b >> LineAABasics.LineSubPixelShift * 2),
                (byte)(a >> LineAABasics.LineSubPixelShift * 2));
        }
Esempio n. 8
0
 public unsafe void create_pmap(uint width, uint height, RasterBuffer wnd)
 {
     m_pmap_window = new PixelMap();
     m_pmap_window.Create(width, height, PlatformSupportAbstract.GetBitDepthForPixelFormat(m_format));
     wnd.Attach(m_pmap_window.buf(),
                m_pmap_window.Width(),
                m_pmap_window.Height(),
                m_RenderOrigin == PlatformSupportAbstract.ERenderOrigin.OriginBottomLeft ? -m_pmap_window.stride() : m_pmap_window.stride(),
                m_pmap_window.bpp());
 }
        public unsafe void PixelHighRes(RasterBuffer buf, RGBA_Bytes* p, int x, int y)
        {
            int r, g, b, a;
            r = g = b = a = LineAABasics.LineSubPixelScale * LineAABasics.LineSubPixelScale / 2;

            int weight;
            int x_lr = x >> LineAABasics.LineSubPixelShift;
            int y_lr = y >> LineAABasics.LineSubPixelShift;

            x &= LineAABasics.LineSubPixelMask;
            y &= LineAABasics.LineSubPixelMask;
            RGBA_Bytes* ptr = (RGBA_Bytes*)buf.GetPixelPointer(x_lr, y_lr);

            weight = (LineAABasics.LineSubPixelScale - x) *
                     (LineAABasics.LineSubPixelScale - y);
            r += weight * ptr->R;
            g += weight * ptr->G;
            b += weight * ptr->B;
            a += weight * ptr->A;

            ++ptr;

            weight = x * (LineAABasics.LineSubPixelScale - y);
            r += weight * ptr->R;
            g += weight * ptr->G;
            b += weight * ptr->B;
            a += weight * ptr->A;

            ptr = (RGBA_Bytes*)buf.GetPixelPointer(x_lr, y_lr + 1);

            weight = (LineAABasics.LineSubPixelScale - x) * y;
            r += weight * ptr->R;
            g += weight * ptr->G;
            b += weight * ptr->B;
            a += weight * ptr->A;

            ++ptr;

            weight = x * y;
            r += weight * ptr->R;
            g += weight * ptr->G;
            b += weight * ptr->B;
            a += weight * ptr->A;
            
            //p->R = (byte)(r >> LineAABasics.LineSubPixelShift * 2);
            //p->G = (byte)(g >> LineAABasics.LineSubPixelShift * 2);
            //p->B = (byte)(b >> LineAABasics.LineSubPixelShift * 2);
            //p->A = (byte)(a >> LineAABasics.LineSubPixelShift * 2);

            (*p) = new RGBA_Bytes(
                (byte)(r >> LineAABasics.LineSubPixelShift * 2),
                (byte)(g >> LineAABasics.LineSubPixelShift * 2),
                (byte)(b >> LineAABasics.LineSubPixelShift * 2),
                (byte)(a >> LineAABasics.LineSubPixelShift * 2));
        }
        // Create
        //--------------------------------------------------------------------
        public line_image_pattern(IPatternFilter filter, RasterBuffer src)
        {
            m_filter         = (filter);
            m_dilation       = (filter.dilation() + 1);
            m_dilation_hr    = (m_dilation << LineAABasics.line_subpixel_shift);
            m_width          = 0;
            m_height         = 0;
            m_width_hr       = 0;
            m_half_height_hr = 0;
            m_offset_y_hr    = (0);
            m_buf            = src;

            create(src);
        }
Esempio n. 11
0
 public void CopyFrom(RasterBuffer sourceBuffer, int xdst, int ydst, int xsrc, int ysrc, uint len)
 {
     unsafe
     {
         byte *pSource = sourceBuffer.GetPixelPointer(ysrc);
         if (pSource != null)
         {
             int BytesPerScanLine = Stride;
             Basics.memmove(m_rbuf.GetPixelPointer(ydst) + xdst * BytesPerScanLine,
                            pSource + xsrc * BytesPerScanLine,
                            (int)len * BytesPerScanLine);
         }
     }
 }
Esempio n. 12
0
        public unsafe void PixelHighResolution(RasterBuffer buf, RGBA_Bytes *p, int x, int y)
        {
            int r, g, b, a;

            r = g = b = a = LineAABasics.line_subpixel_scale * LineAABasics.line_subpixel_scale / 2;

            int weight;
            int x_lr = x >> LineAABasics.line_subpixel_shift;
            int y_lr = y >> LineAABasics.line_subpixel_shift;

            x &= LineAABasics.line_subpixel_mask;
            y &= LineAABasics.line_subpixel_mask;
            RGBA_Bytes *ptr = (RGBA_Bytes *)buf.GetPixelPointer(x_lr, y_lr);

            weight = (LineAABasics.line_subpixel_scale - x) *
                     (LineAABasics.line_subpixel_scale - y);
            r += weight * ptr->m_R;
            g += weight * ptr->m_G;
            b += weight * ptr->m_B;
            a += weight * ptr->m_A;

            ++ptr;

            weight = x * (LineAABasics.line_subpixel_scale - y);
            r     += weight * ptr->m_R;
            g     += weight * ptr->m_G;
            b     += weight * ptr->m_B;
            a     += weight * ptr->m_A;

            ptr = (RGBA_Bytes *)buf.GetPixelPointer(x_lr, y_lr + 1);

            weight = (LineAABasics.line_subpixel_scale - x) * y;
            r     += weight * ptr->m_R;
            g     += weight * ptr->m_G;
            b     += weight * ptr->m_B;
            a     += weight * ptr->m_A;

            ++ptr;

            weight = x * y;
            r     += weight * ptr->m_R;
            g     += weight * ptr->m_G;
            b     += weight * ptr->m_B;
            a     += weight * ptr->m_A;

            p->m_R = (byte)(r >> LineAABasics.line_subpixel_shift * 2);
            p->m_G = (byte)(g >> LineAABasics.line_subpixel_shift * 2);
            p->m_B = (byte)(b >> LineAABasics.line_subpixel_shift * 2);
            p->m_A = (byte)(a >> LineAABasics.line_subpixel_shift * 2);
        }
Esempio n. 13
0
        public unsafe void PixelHighResolution(RasterBuffer buf, RGBA_Bytes* p, int x, int y)
        {
            int r, g, b, a;
            r = g = b = a = LineAABasics.line_subpixel_scale * LineAABasics.line_subpixel_scale / 2;

            int weight;
            int x_lr = x >> LineAABasics.line_subpixel_shift;
            int y_lr = y >> LineAABasics.line_subpixel_shift;

            x &= LineAABasics.line_subpixel_mask;
            y &= LineAABasics.line_subpixel_mask;
            RGBA_Bytes* ptr = (RGBA_Bytes*)buf.GetPixelPointer(x_lr, y_lr);

            weight = (LineAABasics.line_subpixel_scale - x) *
                     (LineAABasics.line_subpixel_scale - y);
            r += weight * ptr->m_R;
            g += weight * ptr->m_G;
            b += weight * ptr->m_B;
            a += weight * ptr->m_A;

            ++ptr;

            weight = x * (LineAABasics.line_subpixel_scale - y);
            r += weight * ptr->m_R;
            g += weight * ptr->m_G;
            b += weight * ptr->m_B;
            a += weight * ptr->m_A;

            ptr = (RGBA_Bytes*)buf.GetPixelPointer(x_lr, y_lr + 1);

            weight = (LineAABasics.line_subpixel_scale - x) * y;
            r += weight * ptr->m_R;
            g += weight * ptr->m_G;
            b += weight * ptr->m_B;
            a += weight * ptr->m_A;

            ++ptr;

            weight = x * y;
            r += weight * ptr->m_R;
            g += weight * ptr->m_G;
            b += weight * ptr->m_B;
            a += weight * ptr->m_A;

            p->m_R = (byte)(r >> LineAABasics.line_subpixel_shift * 2);
            p->m_G = (byte)(g >> LineAABasics.line_subpixel_shift * 2);
            p->m_B = (byte)(b >> LineAABasics.line_subpixel_shift * 2);
            p->m_A = (byte)(a >> LineAABasics.line_subpixel_shift * 2);
        }
Esempio n. 14
0
        //------------------------------------------------------------------------
        public override bool LoadImage(uint idx, string file)
        {
            if (idx < (uint)max_images_e.max_images)
            {
                int len = file.Length;
                if (len < 4 || !file.EndsWith(".BMP"))
                {
                    file += ".bmp";
                }

                RasterBuffer temp     = new RasterBuffer();
                bool         goodLoad = m_specific.load_pmap(file, idx, temp);
                m_rbuf_img.Add(temp);
                return(goodLoad);
            }
            return(true);
        }
Esempio n. 15
0
        public alpha_mask2_application(PixelFormats format, ERenderOrigin RenderOrigin)
            : base(format, RenderOrigin)
        {
            m_alpha_mask_rbuf = new RasterBuffer();
#if USE_CLIPPING_ALPHA_MASK
            m_alpha_mask = new AlphaMaskByteClipped(m_alpha_mask_rbuf, 1, 0);
#else
            m_alpha_mask = new AlphaMaskByteUnclipped(m_alpha_mask_rbuf, 1, 0);
#endif

            m_num_cb       = new UI.SliderWidget <T>(5, 5, 150, 12);
            m_slider_value = M.Zero <T>();
            parse_lion();
            AddChild(m_num_cb);
            m_num_cb.range(5, 100);
            m_num_cb.value(10);
            m_num_cb.label("N={0:F3}");
            m_num_cb.SetTransform(MatrixFactory <T> .NewIdentity(VectorDimension.Two));
        }
        //--------------------------------------------------------------------
        public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len)
        {
            RasterBuffer      SourceRenderingBuffer = base.Source().PixelFormat.GetRenderingBuffer();
            ISpanInterpolator spanInterpolator      = base.Interpolator;

            spanInterpolator.Begin(x + base.FilterDxDbl(), y + base.FilterDyDbl(), len);
            do
            {
                int x_hr;
                int y_hr;
                spanInterpolator.Coordinates(out x_hr, out y_hr);
                int   x_lr   = x_hr >> (int)image_subpixel_scale_e.Shift;
                int   y_lr   = y_hr >> (int)image_subpixel_scale_e.Shift;
                byte *fg_ptr = SourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr * 3);
                //byte* fg_ptr = spanInterpolator.span(x_lr, y_lr, 1);
                (*span).m_R = fg_ptr[OrderR];
                (*span).m_G = fg_ptr[OrderG];
                (*span).m_B = fg_ptr[OrderB];
                (*span).m_A = 255;
                ++span;
                spanInterpolator.Next();
            } while(--len != 0);
        }
Esempio n. 17
0
        //------------------------------------------------------------------------
        public override bool Init(uint width, uint height, uint flags)
        {
            if (m_specific.m_sys_format == PlatformSupportAbstract.PixelFormats.Undefined)
            {
                return(false);
            }

            m_window_flags = flags;

            System.Drawing.Size clientSize = new System.Drawing.Size();
            clientSize.Width      = (int)width;
            clientSize.Height     = (int)height;
            m_specific.ClientSize = clientSize;

            if ((m_window_flags & (uint)EWindowFlags.Risizeable) == 0)
            {
                m_specific.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
                m_specific.MaximizeBox     = false;
            }

            m_rbuf_window = new RasterBuffer();
            m_specific.create_pmap(width, height, m_rbuf_window);
            m_initial_width  = width;
            m_initial_height = height;

            m_specific.Show();

            m_Bounds.Bottom = 0;
            m_Bounds.Left   = 0;
            m_Bounds.Top    = height;
            m_Bounds.Right  = width;

            OnInitialize();
            m_specific.m_WindowContentNeedsRedraw = true;

            return(true);
        }
Esempio n. 18
0
        public void CopyFrom(RasterBuffer src,
                             RectInt rect_src_ptr,
                             int dx,
                             int dy)
        {
            RectInt rsrc = new RectInt(rect_src_ptr.X1, rect_src_ptr.Y1, rect_src_ptr.X2 + 1, rect_src_ptr.Y2 + 1);

            // Version with xdst, ydst (absolute positioning)
            //rect_i rdst(xdst, ydst, xdst + rsrc.x2 - rsrc.x1, ydst + rsrc.y2 - rsrc.y1);

            // Version with dx, dy (relative positioning)
            RectInt rdst = new RectInt(rsrc.X1 + dx, rsrc.Y1 + dy, rsrc.X2 + dx, rsrc.Y2 + dy);

            RectInt rc = ClipRectArea(ref rdst, ref rsrc, (int)src.Width, (int)src.Height);

            if (rc.X2 > 0)
            {
                int incy = 1;
                if (rdst.Y1 > rsrc.Y1)
                {
                    rsrc.Y1 += rc.Y2 - 1;
                    rdst.Y1 += rc.Y2 - 1;
                    incy     = -1;
                }
                while (rc.Y2 > 0)
                {
                    base.CopyFrom(src,
                                  rdst.X1, rdst.Y1,
                                  rsrc.X1, rsrc.Y1,
                                  (uint)rc.X2);
                    rdst.Y1 += incy;
                    rsrc.Y1 += incy;
                    --rc.Y2;
                }
            }
        }
Esempio n. 19
0
        public void CopyFrom(RasterBuffer src,
                             RectI rect_src_ptr,
                             int dx,
                             int dy)
        {
            RectI rsrc = new RectI(rect_src_ptr.x1, rect_src_ptr.y1, rect_src_ptr.x2 + 1, rect_src_ptr.y2 + 1);

            // Version with xdst, ydst (absolute positioning)
            //RectI rdst(xdst, ydst, xdst + rsrc.x2 - rsrc.x1, ydst + rsrc.y2 - rsrc.y1);

            // Version with dx, dy (relative positioning)
            RectI rdst = new RectI(rsrc.x1 + dx, rsrc.y1 + dy, rsrc.x2 + dx, rsrc.y2 + dy);

            RectI rc = ClipRectangleArea(ref rdst, ref rsrc, (int)src.Width(), (int)src.Height());

            if (rc.x2 > 0)
            {
                int incy = 1;
                if (rdst.y1 > rsrc.y1)
                {
                    rsrc.y1 += rc.y2 - 1;
                    rdst.y1 += rc.y2 - 1;
                    incy     = -1;
                }
                while (rc.y2 > 0)
                {
                    base.CopyFrom(src,
                                  rdst.x1, rdst.y1,
                                  rsrc.x1, rsrc.y1,
                                  (uint)rc.x2);
                    rdst.y1 += incy;
                    rsrc.y1 += incy;
                    --rc.y2;
                }
            }
        }
Esempio n. 20
0
		public void CopyFrom(RasterBuffer sourceBuffer, int xdst, int ydst, int xsrc, int ysrc, uint len)
		{
			unsafe
			{
				Basics.memmove(&m_rbuf.GetPixelPointer(ydst)[xdst * 4],
						&sourceBuffer.GetPixelPointer(ysrc)[xsrc * 4],
						(int)len * 4);
			}
		}
Esempio n. 21
0
		public FormatRGBA(RasterBuffer rb, IBlender blender)
		{
			m_rbuf = rb;
			Blender = blender;
		}
Esempio n. 22
0
 public virtual void CopyFrom(RasterBuffer from, int xdst, int ydst, int xsrc, int ysrc, uint len)
 {
     PixelFormat.CopyFrom(from, xdst, ydst, xsrc, ysrc, len);
 }
Esempio n. 23
0
 public void Attach(RasterBuffer rbuf)
 {
     m_rbuf = rbuf;
 }
Esempio n. 24
0
 ///<summary>
 ///</summary>
 ///<param name="rb"></param>
 ///<param name="blender"></param>
 ///<param name="gammaTable"></param>
 public FormatRGB(RasterBuffer rb, IBlender blender, GammaLookupTable gammaTable)
 {
     _rasterBuffer = rb;
     Blender       = blender;
 }
Esempio n. 25
0
        //------------------------------------------------------------------------
        public override bool Init(uint width, uint height, uint flags)
        {
            if (m_specific.m_sys_format == PlatformSupportAbstract.PixelFormats.Undefined)
            {
                return false;
            }

            m_window_flags = flags;

            System.Drawing.Size clientSize = new System.Drawing.Size();
            clientSize.Width = (int)width;
            clientSize.Height = (int)height;
            m_specific.ClientSize = clientSize;

            if ((m_window_flags & (uint)EWindowFlags.Risizeable) == 0)
            {
                m_specific.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
                m_specific.MaximizeBox = false;
            }

            m_rbuf_window = new RasterBuffer();
            m_specific.create_pmap(width, height, m_rbuf_window);
            m_initial_width = width;
            m_initial_height = height;

            m_specific.Show();

            m_Bounds.Bottom = 0;
            m_Bounds.Left = 0;
            m_Bounds.Top = height;
            m_Bounds.Right = width;

            OnInitialize();
            m_specific.m_WindowContentNeedsRedraw = true;

            return true;
        }
Esempio n. 26
0
 public void Attach(RasterBuffer rb)
 {
     _rasterBuffer = rb;
 }
 public void Attach(RasterBuffer rbuf) { m_rbuf = rbuf; }
Esempio n. 28
0
 ///<summary>
 ///</summary>
 ///<param name="rb"></param>
 ///<param name="blender"></param>
 public FormatRGB(RasterBuffer rb, IBlender blender)
 {
     _rasterBuffer = rb;
     Blender = blender;
 }
Esempio n. 29
0
 ///<summary>
 ///</summary>
 ///<param name="rb"></param>
 ///<param name="blender"></param>
 ///<param name="gammaTable"></param>
 public FormatRGB(RasterBuffer rb, IBlender blender, GammaLookupTable gammaTable)
 {
     _rasterBuffer = rb;
     Blender = blender;
 }
        unsafe private void BlendInFilterPixel(uint *fg, ref uint src_alpha, uint back_r, uint back_g, uint back_b, uint back_a, RasterBuffer SourceRenderingBuffer, int maxx, int maxy, int x_lr, int y_lr, uint weight)
        {
            byte *fg_ptr;

            unchecked
            {
                if ((uint)x_lr <= (uint)maxx && (uint)y_lr <= (uint)maxy)
                {
                    fg_ptr = SourceRenderingBuffer.GetPixelPointer(y_lr) + x_lr * 3;

                    fg[0]     += weight * fg_ptr[0];
                    fg[1]     += weight * fg_ptr[1];
                    fg[2]     += weight * fg_ptr[2];
                    src_alpha += weight * BaseMask;
                }
                else
                {
                    fg[OrderR] += back_r * weight;
                    fg[OrderG] += back_g * weight;
                    fg[OrderB] += back_b * weight;
                    src_alpha  += back_a * weight;
                }
            }
        }
        // Create
        //--------------------------------------------------------------------
        public void create(RasterBuffer src)
        {
            m_height = (int)agg_basics.uceil(src.Height());
            m_width = (int)agg_basics.uceil(src.Width());
            m_width_hr = (int)agg_basics.uround(src.Width() * LineAABasics.line_subpixel_scale);
            m_half_height_hr = (int)agg_basics.uround(src.Height() * LineAABasics.line_subpixel_scale / 2);
            m_offset_y_hr = m_dilation_hr + m_half_height_hr - LineAABasics.line_subpixel_scale / 2;
            m_half_height_hr += LineAABasics.line_subpixel_scale / 2;

            int NewSizeInBytes = (m_width + m_dilation * 2) * (m_height + m_dilation * 2);
            if (m_DataSizeInBytes < NewSizeInBytes)
            {
                if (m_data != null)
                {
                    System.Runtime.InteropServices.Marshal.FreeHGlobal(m_data);
                }
                m_DataSizeInBytes = NewSizeInBytes;
                m_data = System.Runtime.InteropServices.Marshal.AllocHGlobal(m_DataSizeInBytes);
            }

            unsafe
            {
                m_buf.attach((byte*)m_data,
                    (uint)(m_width + m_dilation * 2),
                    (uint)(m_height + m_dilation * 2),
                    (int)(m_width + m_dilation * 2),
                    32);

                int x, y;
                RGBA_Bytes* d1;
                RGBA_Bytes* d2;
                for (y = 0; y < m_height; y++)
                {
                    d1 = (RGBA_Bytes*)m_buf.GetPixelPointer(y + m_dilation) + m_dilation;
                    for (x = 0; x < m_width; x++)
                    {
                        *d1++ = *(RGBA_Bytes*)src.GetPixelPointer(x, y);
                    }
                }

                RGBA_Bytes* s1;
                RGBA_Bytes* s2;
                RGBA_Bytes noColor = (RGBA_Bytes)RGBA_Bytes.no_color();
                for (y = 0; y < m_dilation; y++)
                {
                    //s1 = m_buf.GetPixelPointer(m_height + m_dilation - 1) + m_dilation;
                    //s2 = m_buf.GetPixelPointer(m_dilation) + m_dilation;
                    d1 = (RGBA_Bytes*)m_buf.GetPixelPointer(m_dilation + m_height + y) + m_dilation;
                    d2 = (RGBA_Bytes*)m_buf.GetPixelPointer(m_dilation - y - 1) + m_dilation;
                    for (x = 0; x < m_width; x++)
                    {
                        //*d1++ = RGBA_Bytes(*s1++, 0);
                        //*d2++ = RGBA_Bytes(*s2++, 0);
                        *d1++ = noColor;
                        *d2++ = noColor;
                    }
                }

                int h = m_height + m_dilation * 2;
                for (y = 0; y < h; y++)
                {
                    s1 = (RGBA_Bytes*)m_buf.GetPixelPointer(y) + m_dilation;
                    s2 = (RGBA_Bytes*)m_buf.GetPixelPointer(y) + m_dilation + m_width;
                    d1 = (RGBA_Bytes*)m_buf.GetPixelPointer(y) + m_dilation + m_width;
                    d2 = (RGBA_Bytes*)m_buf.GetPixelPointer(y) + m_dilation;

                    for (x = 0; x < m_dilation; x++)
                    {
                        *d1++ = *s1++;
                        *--d2 = *--s2;
                    }
                }
            }
        }
        // Create
        //--------------------------------------------------------------------
        public line_image_pattern(IPatternFilter filter, RasterBuffer src)
        {
            m_filter=(filter);
            m_dilation=(filter.dilation() + 1);
            m_dilation_hr=(m_dilation << LineAABasics.line_subpixel_shift);
            m_width=0;
            m_height=0;
            m_width_hr=0;
            m_half_height_hr=0;
            m_offset_y_hr=(0);
            m_buf = src;

            create(src);
        }
Esempio n. 33
0
 public void CopyFrom(RasterBuffer sourceBuffer, int xdst, int ydst, int xsrc, int ysrc, uint len)
 {
     unsafe
     {
         byte* pSource = sourceBuffer.GetPixelPointer(ysrc);
         if (pSource != null)
         {
             int BytesPerScanLine = Stride;
             Basics.memmove(m_rbuf.GetPixelPointer(ydst) + xdst * BytesPerScanLine,
                     pSource + xsrc * BytesPerScanLine,
                     (int)len * BytesPerScanLine);
         }
     }
 }
Esempio n. 34
0
 public virtual void CopyFrom(RasterBuffer from, int xdst, int ydst, int xsrc, int ysrc, uint len)
 {
     m_pixf.CopyFrom(from, xdst, ydst, xsrc, ysrc, len);
 }
        unsafe private void BlendInFilterPixel(uint *fg, uint back_r, uint back_g, uint back_b, uint back_a, RasterBuffer pSourceRenderingBuffer, int maxx, int maxy, int x_lr, int y_lr, uint weight)
        {
            unchecked
            {
                byte *fg_ptr;
                if ((uint)x_lr <= (uint)maxx && (uint)y_lr <= (uint)maxy)
                {
                    fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                    fg[0] += weight * fg_ptr[0];
                    fg[1] += weight * fg_ptr[1];
                    fg[2] += weight * fg_ptr[2];
                    fg[3] += weight * fg_ptr[3];
                }
                else
                {
                    fg[OrderR] += back_r * weight;
                    fg[OrderG] += back_g * weight;
                    fg[OrderB] += back_b * weight;
                    fg[OrderA] += back_a * weight;
                }
            }
        }
Esempio n. 36
0
 public override void CopyFrom(RasterBuffer from, int xdst, int ydst, int xsrc, int ysrc, uint len)
 {
     throw new System.NotImplementedException();
 }
Esempio n. 37
0
 public void Attach(RasterBuffer rb)
 {
     _rasterBuffer = rb;
 }
Esempio n. 38
0
 ///<summary>
 ///</summary>
 ///<param name="rbuf"></param>
 ///<param name="step"></param>
 ///<param name="offset"></param>
 public AlphaMaskByteUnclipped(RasterBuffer rbuf, uint step, uint offset)
 {
     _step = step;
     _offset = offset;
     _rasterBuffer = rbuf;
 }
Esempio n. 39
0
        //------------------------------------------------------------------------
        public override bool LoadImage(uint idx, string file)
        {
            if (idx < (uint)max_images_e.max_images)
            {
                int len = file.Length;
                if (len < 4 || !file.EndsWith(".BMP"))
                {
                    file += ".bmp";
                }

                RasterBuffer temp = new RasterBuffer();
                bool goodLoad = m_specific.load_pmap(file, idx, temp);
                m_rbuf_img.Add(temp);
                return goodLoad;
            }
            return true;
        }
        // Create
        //--------------------------------------------------------------------
        public void create(RasterBuffer src)
        {
            m_height          = (int)agg_basics.uceil(src.Height());
            m_width           = (int)agg_basics.uceil(src.Width());
            m_width_hr        = (int)agg_basics.uround(src.Width() * LineAABasics.line_subpixel_scale);
            m_half_height_hr  = (int)agg_basics.uround(src.Height() * LineAABasics.line_subpixel_scale / 2);
            m_offset_y_hr     = m_dilation_hr + m_half_height_hr - LineAABasics.line_subpixel_scale / 2;
            m_half_height_hr += LineAABasics.line_subpixel_scale / 2;

            int NewSizeInBytes = (m_width + m_dilation * 2) * (m_height + m_dilation * 2);

            if (m_DataSizeInBytes < NewSizeInBytes)
            {
                if (m_data != null)
                {
                    System.Runtime.InteropServices.Marshal.FreeHGlobal(m_data);
                }
                m_DataSizeInBytes = NewSizeInBytes;
                m_data            = System.Runtime.InteropServices.Marshal.AllocHGlobal(m_DataSizeInBytes);
            }

            unsafe
            {
                m_buf.attach((byte *)m_data,
                             (uint)(m_width + m_dilation * 2),
                             (uint)(m_height + m_dilation * 2),
                             (int)(m_width + m_dilation * 2),
                             32);

                int         x, y;
                RGBA_Bytes *d1;
                RGBA_Bytes *d2;
                for (y = 0; y < m_height; y++)
                {
                    d1 = (RGBA_Bytes *)m_buf.GetPixelPointer(y + m_dilation) + m_dilation;
                    for (x = 0; x < m_width; x++)
                    {
                        *d1++ = *(RGBA_Bytes *)src.GetPixelPointer(x, y);
                    }
                }

                RGBA_Bytes *s1;
                RGBA_Bytes *s2;
                RGBA_Bytes  noColor = (RGBA_Bytes)RGBA_Bytes.no_color();
                for (y = 0; y < m_dilation; y++)
                {
                    //s1 = m_buf.GetPixelPointer(m_height + m_dilation - 1) + m_dilation;
                    //s2 = m_buf.GetPixelPointer(m_dilation) + m_dilation;
                    d1 = (RGBA_Bytes *)m_buf.GetPixelPointer(m_dilation + m_height + y) + m_dilation;
                    d2 = (RGBA_Bytes *)m_buf.GetPixelPointer(m_dilation - y - 1) + m_dilation;
                    for (x = 0; x < m_width; x++)
                    {
                        //*d1++ = RGBA_Bytes(*s1++, 0);
                        //*d2++ = RGBA_Bytes(*s2++, 0);
                        *d1++ = noColor;
                        *d2++ = noColor;
                    }
                }

                int h = m_height + m_dilation * 2;
                for (y = 0; y < h; y++)
                {
                    s1 = (RGBA_Bytes *)m_buf.GetPixelPointer(y) + m_dilation;
                    s2 = (RGBA_Bytes *)m_buf.GetPixelPointer(y) + m_dilation + m_width;
                    d1 = (RGBA_Bytes *)m_buf.GetPixelPointer(y) + m_dilation + m_width;
                    d2 = (RGBA_Bytes *)m_buf.GetPixelPointer(y) + m_dilation;

                    for (x = 0; x < m_dilation; x++)
                    {
                        *d1++ = *s1++;
                        *--d2 = *--s2;
                    }
                }
            }
        }
Esempio n. 41
0
 public AlphaMaskByteUnclipped(RasterBuffer rbuf, uint Step, uint Offset)
 {
     m_Step   = Step;
     m_Offset = Offset;
     m_rbuf   = rbuf;
 }
Esempio n. 42
0
 public virtual void CopyFrom(RasterBuffer from, int xdst, int ydst, int xsrc, int ysrc, uint len)
 {
     PixelFormat.CopyFrom(from, xdst, ydst, xsrc, ysrc, len);
 }
Esempio n. 43
0
        public blur_application(PixelFormats format, ERenderOrigin RenderOrigin)
            : base(format, RenderOrigin)
        {
            m_rbuf2         = new RasterBuffer();
            m_shape_bounds  = new RectDouble <T>();
            m_method        = new rbox_ctrl <T>(10.0, 10.0, 130.0, 70.0);
            m_radius        = new SliderWidget <T>(130 + 10.0, 10.0 + 4.0, 130 + 300.0, 10.0 + 8.0 + 4.0);
            m_shadow_ctrl   = new polygon_ctrl <T>(4);
            m_channel_r     = new cbox_ctrl <T>(10.0, 80.0, "Red");
            m_channel_g     = new cbox_ctrl <T>(10.0, 95.0, "Green");
            m_channel_b     = new cbox_ctrl <T>(10.0, 110.0, "Blue");
            m_FlattenCurves = new cbox_ctrl <T>(10, 315, "Convert And Flatten Curves");
            m_FlattenCurves.status(true);

            AddChild(m_method);
            m_method.text_size(8);
            m_method.add_item("Stack Blur");
            m_method.add_item("Recursive Blur");
            m_method.add_item("Channels");
            m_method.cur_item(1);

            AddChild(m_radius);
            m_radius.range(0.0, 40.0);
            m_radius.value(15.0);
            m_radius.label("Blur Radius={0:F2}");

            AddChild(m_shadow_ctrl);

            AddChild(m_channel_r);
            AddChild(m_channel_g);
            AddChild(m_channel_b);
            AddChild(m_FlattenCurves);
            m_channel_g.status(true);

            m_sl    = new ScanlinePacked8();
            m_path  = new PathStorage <T>();
            m_shape = new ConvCurve <T>(m_path);

            m_path.RemoveAll();
            m_path.MoveTo(28.47, 6.45);
            m_path.Curve3(21.58, 1.12, 19.82, 0.29);
            m_path.Curve3(17.19, -0.93, 14.21, -0.93);
            m_path.Curve3(9.57, -0.93, 6.57, 2.25);
            m_path.Curve3(3.56, 5.42, 3.56, 10.60);
            m_path.Curve3(3.56, 13.87, 5.03, 16.26);
            m_path.Curve3(7.03, 19.58, 11.99, 22.51);
            m_path.Curve3(16.94, 25.44, 28.47, 29.64);
            m_path.LineTo(28.47, 31.40);
            m_path.Curve3(28.47, 38.09, 26.34, 40.58);
            m_path.Curve3(24.22, 43.07, 20.17, 43.07);
            m_path.Curve3(17.09, 43.07, 15.28, 41.41);
            m_path.Curve3(13.43, 39.75, 13.43, 37.60);
            m_path.LineTo(13.53, 34.77);
            m_path.Curve3(13.53, 32.52, 12.38, 31.30);
            m_path.Curve3(11.23, 30.08, 9.38, 30.08);
            m_path.Curve3(7.57, 30.08, 6.42, 31.35);
            m_path.Curve3(5.27, 32.62, 5.27, 34.81);
            m_path.Curve3(5.27, 39.01, 9.57, 42.53);
            m_path.Curve3(13.87, 46.04, 21.63, 46.04);
            m_path.Curve3(27.59, 46.04, 31.40, 44.04);
            m_path.Curve3(34.28, 42.53, 35.64, 39.31);
            m_path.Curve3(36.52, 37.21, 36.52, 30.71);
            m_path.LineTo(36.52, 15.53);
            m_path.Curve3(36.52, 9.13, 36.77, 7.69);
            m_path.Curve3(37.01, 6.25, 37.57, 5.76);
            m_path.Curve3(38.13, 5.27, 38.87, 5.27);
            m_path.Curve3(39.65, 5.27, 40.23, 5.62);
            m_path.Curve3(41.26, 6.25, 44.19, 9.18);
            m_path.LineTo(44.19, 6.45);
            m_path.Curve3(38.72, -0.88, 33.74, -0.88);
            m_path.Curve3(31.35, -0.88, 29.93, 0.78);
            m_path.Curve3(28.52, 2.44, 28.47, 6.45);
            m_path.ClosePolygon();

            m_path.MoveTo(28.47, 9.62);
            m_path.LineTo(28.47, 26.66);
            m_path.Curve3(21.09, 23.73, 18.95, 22.51);
            m_path.Curve3(15.09, 20.36, 13.43, 18.02);
            m_path.Curve3(11.77, 15.67, 11.77, 12.89);
            m_path.Curve3(11.77, 9.38, 13.87, 7.06);
            m_path.Curve3(15.97, 4.74, 18.70, 4.74);
            m_path.Curve3(22.41, 4.74, 28.47, 9.62);
            m_path.ClosePolygon();

            IAffineTransformMatrix <T> shape_mtx = MatrixFactory <T> .NewIdentity(VectorDimension.Two);

            shape_mtx.Scale(M.New <T>(4.0));
            shape_mtx.Translate(MatrixFactory <T> .CreateVector2D(150, 100));
            m_path.Transform(shape_mtx);

            BoundingRect <T> .BoundingRectSingle(m_shape, 0, ref m_shape_bounds);

            m_shadow_ctrl.SetXN(0, m_shape_bounds.x1);
            m_shadow_ctrl.SetYN(0, m_shape_bounds.y1);
            m_shadow_ctrl.SetXN(1, m_shape_bounds.x2);
            m_shadow_ctrl.SetYN(1, m_shape_bounds.y1);
            m_shadow_ctrl.SetXN(2, m_shape_bounds.x2);
            m_shadow_ctrl.SetYN(2, m_shape_bounds.y2);
            m_shadow_ctrl.SetXN(3, m_shape_bounds.x1);
            m_shadow_ctrl.SetYN(3, m_shape_bounds.y2);
            m_shadow_ctrl.line_color(new RGBA_Doubles(0, 0.3, 0.5, 0.3));
        }
        public unsafe void Generate(out RGBA_Bytes destPixel, int x, int y)
        {
            base.Interpolator.Begin(M.New <T>(x).Add(base.FilterDxDbl()), M.New <T>(y).Add(base.FilterDyDbl()), 1);

            uint *fg = stackalloc uint[4];

            byte *fg_ptr;

            RasterBuffer          pSourceRenderingBuffer = base.Source().PixelFormat.GetRenderingBuffer();
            int                   maxx             = (int)pSourceRenderingBuffer.Width - 1;
            int                   maxy             = (int)pSourceRenderingBuffer.Height - 1;
            ISpanInterpolator <T> spanInterpolator = base.Interpolator;

            unchecked
            {
                int x_hr;
                int y_hr;

                spanInterpolator.Coordinates(out x_hr, out y_hr);

                x_hr -= base.FilterDxInt();
                y_hr -= base.FilterDyInt();

                int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift;
                int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift;

                uint weight;

                fg[0] = fg[1] = fg[2] = fg[3] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2;

                x_hr &= (int)image_subpixel_scale_e.Mask;
                y_hr &= (int)image_subpixel_scale_e.Mask;

                fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) *
                                ((int)image_subpixel_scale_e.Scale - y_hr));
                fg[0] += weight * fg_ptr[0];
                fg[1] += weight * fg_ptr[1];
                fg[2] += weight * fg_ptr[2];
                fg[3] += weight * fg_ptr[3];

                weight = (uint)(x_hr * ((int)image_subpixel_scale_e.Scale - y_hr));
                fg[0] += weight * fg_ptr[4];
                fg[1] += weight * fg_ptr[5];
                fg[2] += weight * fg_ptr[6];
                fg[3] += weight * fg_ptr[7];

                ++y_lr;
                fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * y_hr);
                fg[0] += weight * fg_ptr[0];
                fg[1] += weight * fg_ptr[1];
                fg[2] += weight * fg_ptr[2];
                fg[3] += weight * fg_ptr[3];

                weight = (uint)(x_hr * y_hr);
                fg[0] += weight * fg_ptr[4];
                fg[1] += weight * fg_ptr[5];
                fg[2] += weight * fg_ptr[6];
                fg[3] += weight * fg_ptr[7];

                fg[0] >>= (int)image_subpixel_scale_e.Shift * 2;
                fg[1] >>= (int)image_subpixel_scale_e.Shift * 2;
                fg[2] >>= (int)image_subpixel_scale_e.Shift * 2;
                fg[3] >>= (int)image_subpixel_scale_e.Shift * 2;

                destPixel = new RGBA_Bytes((byte)fg[OrderR], (byte)fg[OrderG], (byte)fg[OrderB], (byte)fg[OrderA]);

                //destPixel.R = (byte)fg[OrderR];
                //destPixel.G = (byte)fg[OrderG];
                //destPixel.B = (byte)fg[OrderB];
                //destPixel.A = (byte)fg[OrderA];
            }
        }
Esempio n. 45
0
		//--------------------------------------------------------------------
		public FormatRGBA(RasterBuffer rb, IBlender blender, GammaLookupTable gammaTable)
			: this(rb, blender)
		{
			throw new System.NotImplementedException("Not using the Gamma table yet.");
		}
        public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len)
        {
#if use_timers
            Generate_Span.Start();
#endif
            base.Interpolator.Begin(M.New <T>(x).Add(base.FilterDxDbl()), M.New <T>(y).Add(base.FilterDyDbl()), len);

            uint *fg = stackalloc uint[4];

            byte *fg_ptr;

            RasterBuffer          pSourceRenderingBuffer = base.Source().PixelFormat.GetRenderingBuffer();
            int                   maxx             = (int)pSourceRenderingBuffer.Width - 1;
            int                   maxy             = (int)pSourceRenderingBuffer.Height - 1;
            ISpanInterpolator <T> spanInterpolator = base.Interpolator;

            unchecked
            {
                do
                {
                    int x_hr;
                    int y_hr;

                    spanInterpolator.Coordinates(out x_hr, out y_hr);

                    x_hr -= base.FilterDxInt();
                    y_hr -= base.FilterDyInt();

                    int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift;
                    int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift;

                    uint weight;

                    fg[0] = fg[1] = fg[2] = fg[3] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2;

                    x_hr &= (int)image_subpixel_scale_e.Mask;
                    y_hr &= (int)image_subpixel_scale_e.Mask;

                    fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                    weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) *
                                    ((int)image_subpixel_scale_e.Scale - y_hr));
                    fg[0] += weight * fg_ptr[0];
                    fg[1] += weight * fg_ptr[1];
                    fg[2] += weight * fg_ptr[2];
                    fg[3] += weight * fg_ptr[3];

                    weight = (uint)(x_hr * ((int)image_subpixel_scale_e.Scale - y_hr));
                    fg[0] += weight * fg_ptr[4];
                    fg[1] += weight * fg_ptr[5];
                    fg[2] += weight * fg_ptr[6];
                    fg[3] += weight * fg_ptr[7];

                    ++y_lr;
                    fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                    weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * y_hr);
                    fg[0] += weight * fg_ptr[0];
                    fg[1] += weight * fg_ptr[1];
                    fg[2] += weight * fg_ptr[2];
                    fg[3] += weight * fg_ptr[3];

                    weight = (uint)(x_hr * y_hr);
                    fg[0] += weight * fg_ptr[4];
                    fg[1] += weight * fg_ptr[5];
                    fg[2] += weight * fg_ptr[6];
                    fg[3] += weight * fg_ptr[7];

                    fg[0] >>= (int)image_subpixel_scale_e.Shift * 2;
                    fg[1] >>= (int)image_subpixel_scale_e.Shift * 2;
                    fg[2] >>= (int)image_subpixel_scale_e.Shift * 2;
                    fg[3] >>= (int)image_subpixel_scale_e.Shift * 2;

                    //(*span).R = (byte)fg[OrderR];
                    //(*span).G = (byte)fg[OrderG];
                    //(*span).B = (byte)fg[OrderB];
                    //(*span).A = (byte)fg[OrderA];

                    (*span) = new RGBA_Bytes((byte)fg[OrderR], (byte)fg[OrderG], (byte)fg[OrderB], (byte)fg[OrderA]);

                    ++span;
                    spanInterpolator.Next();
                } while (--len != 0);
            }
#if use_timers
            Generate_Span.Stop();
#endif
        }
Esempio n. 47
0
		public void attach(RasterBuffer rb) { m_rbuf = rb; }
        public unsafe override void Generate(RGBA_Bytes *span, int x, int y, uint len)
        {
#if use_timers
            Generate_Span.Start();
#endif
            base.Interpolator.Begin(M.New <T>(x).Add(base.FilterDxDbl()), M.New <T>(y).Add(base.FilterDyDbl()), len);

            //uint[] fg = new uint[4];
            uint *fg = stackalloc uint[4];

            uint back_r = m_back_color.R;
            uint back_g = m_back_color.G;
            uint back_b = m_back_color.B;
            uint back_a = m_back_color.A;

            byte *fg_ptr;

            RasterBuffer          pSourceRenderingBuffer = base.Source().PixelFormat.GetRenderingBuffer();
            int                   maxx             = (int)pSourceRenderingBuffer.Width - 1;
            int                   maxy             = (int)pSourceRenderingBuffer.Height - 1;
            ISpanInterpolator <T> spanInterpolator = base.Interpolator;

            unchecked
            {
                do
                {
                    int x_hr;
                    int y_hr;

                    spanInterpolator.Coordinates(out x_hr, out y_hr);

                    x_hr -= base.FilterDxInt();
                    y_hr -= base.FilterDyInt();

                    int x_lr = x_hr >> (int)image_subpixel_scale_e.Shift;
                    int y_lr = y_hr >> (int)image_subpixel_scale_e.Shift;

                    uint weight;

                    if (x_lr >= 0 && y_lr >= 0 &&
                        x_lr < maxx && y_lr < maxy)
                    {
                        fg[0]             =
                            fg[1]         =
                                fg[2]     =
                                    fg[3] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2;

                        x_hr &= (int)image_subpixel_scale_e.Mask;
                        y_hr &= (int)image_subpixel_scale_e.Mask;

                        fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                        weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) *
                                        ((int)image_subpixel_scale_e.Scale - y_hr));
                        fg[0] += weight * fg_ptr[0];
                        fg[1] += weight * fg_ptr[1];
                        fg[2] += weight * fg_ptr[2];
                        fg[3] += weight * fg_ptr[3];

                        weight = (uint)(x_hr * ((int)image_subpixel_scale_e.Scale - y_hr));
                        fg[0] += weight * fg_ptr[4];
                        fg[1] += weight * fg_ptr[5];
                        fg[2] += weight * fg_ptr[6];
                        fg[3] += weight * fg_ptr[7];

                        ++y_lr;
                        fg_ptr = pSourceRenderingBuffer.GetPixelPointer(y_lr) + (x_lr << 2);

                        weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * y_hr);
                        fg[0] += weight * fg_ptr[0];
                        fg[1] += weight * fg_ptr[1];
                        fg[2] += weight * fg_ptr[2];
                        fg[3] += weight * fg_ptr[3];

                        weight = (uint)(x_hr * y_hr);
                        fg[0] += weight * fg_ptr[4];
                        fg[1] += weight * fg_ptr[5];
                        fg[2] += weight * fg_ptr[6];
                        fg[3] += weight * fg_ptr[7];

                        fg[0] >>= (int)image_subpixel_scale_e.Shift * 2;
                        fg[1] >>= (int)image_subpixel_scale_e.Shift * 2;
                        fg[2] >>= (int)image_subpixel_scale_e.Shift * 2;
                        fg[3] >>= (int)image_subpixel_scale_e.Shift * 2;
                    }
                    else
                    {
                        if (x_lr < -1 || y_lr < -1 ||
                            x_lr > maxx || y_lr > maxy)
                        {
                            fg[OrderR] = back_r;
                            fg[OrderG] = back_g;
                            fg[OrderB] = back_b;
                            fg[OrderA] = back_a;
                        }
                        else
                        {
                            fg[0]             =
                                fg[1]         =
                                    fg[2]     =
                                        fg[3] = (int)image_subpixel_scale_e.Scale * (int)image_subpixel_scale_e.Scale / 2;

                            x_hr &= (int)image_subpixel_scale_e.Mask;
                            y_hr &= (int)image_subpixel_scale_e.Mask;

                            weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) *
                                            ((int)image_subpixel_scale_e.Scale - y_hr));
                            BlendInFilterPixel(fg, back_r, back_g, back_b, back_a, pSourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight);

                            x_lr++;

                            weight = (uint)(x_hr * ((int)image_subpixel_scale_e.Scale - y_hr));
                            BlendInFilterPixel(fg, back_r, back_g, back_b, back_a, pSourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight);

                            x_lr--;
                            y_lr++;

                            weight = (uint)(((int)image_subpixel_scale_e.Scale - x_hr) * y_hr);
                            BlendInFilterPixel(fg, back_r, back_g, back_b, back_a, pSourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight);

                            x_lr++;

                            weight = (uint)(x_hr * y_hr);
                            BlendInFilterPixel(fg, back_r, back_g, back_b, back_a, pSourceRenderingBuffer, maxx, maxy, x_lr, y_lr, weight);

                            fg[0] >>= (int)image_subpixel_scale_e.Shift * 2;
                            fg[1] >>= (int)image_subpixel_scale_e.Shift * 2;
                            fg[2] >>= (int)image_subpixel_scale_e.Shift * 2;
                            fg[3] >>= (int)image_subpixel_scale_e.Shift * 2;
                        }
                    }

                    //(*span).R = (byte)fg[0];
                    //(*span).G = (byte)fg[1];
                    //(*span).B = (byte)fg[2];
                    //(*span).A = (byte)fg[3];

                    (*span) = new RGBA_Bytes((byte)fg[0], (byte)fg[1], (byte)fg[2], (byte)fg[3]);

                    ++span;
                    spanInterpolator.Next();
                } while (--len != 0);
            }
#if use_timers
            Generate_Span.Stop();
#endif
        }
 public AlphaMaskByteUnclipped(RasterBuffer rbuf, uint Step, uint Offset)
 {
     m_Step = Step;
     m_Offset = Offset;
     m_rbuf = rbuf;
 }
Esempio n. 50
0
 //--------------------------------------------------------------------
 //--------------------------------------------------------------------
 public FormatGray(RasterBuffer rb, IBlenderGray blender, uint step, uint offset)
 {
     m_rbuf = rb;
     Blender = blender;
     m_Step = step;
     m_Offset = offset;
 }
 public unsafe void create_pmap(uint width, uint height, RasterBuffer wnd)
 {
     m_pmap_window = new PixelMap();
     m_pmap_window.Create(width, height, PlatformSupportAbstract.GetBitDepthForPixelFormat(m_format));
     wnd.Attach(m_pmap_window.buf(),
         m_pmap_window.Width(),
         m_pmap_window.Height(),
         m_RenderOrigin == PlatformSupportAbstract.ERenderOrigin.OriginBottomLeft ? -m_pmap_window.stride() : m_pmap_window.stride(),
         m_pmap_window.bpp());
 }
Esempio n. 52
0
 public FormatRGB(RasterBuffer rb, IBlender blender, GammaLut gammaTable)
 {
     m_rbuf = rb;
     Blender = blender;
 }
Esempio n. 53
0
 public void attach(RasterBuffer rb)
 {
     m_rbuf = rb;
 }
        public void display_pmap(Graphics displayGraphics, RasterBuffer src)
        {
            if (m_sys_format == m_format)
            {
                m_pmap_window.Draw(displayGraphics);
            }
            else
            {
                PixelMap pmap_tmp = new PixelMap();
                pmap_tmp.Create(m_pmap_window.Width(),
                    m_pmap_window.Height(), PlatformSupportAbstract.GetBitDepthForPixelFormat(m_sys_format));

                RasterBuffer rbuf_tmp = new RasterBuffer();
                unsafe
                {
                    rbuf_tmp.Attach(pmap_tmp.buf(),
                        pmap_tmp.Width(),
                        pmap_tmp.Height(),
                        m_app.FlipY() ?
                        pmap_tmp.stride() :
                        -pmap_tmp.stride(), pmap_tmp.bpp());
                }

                convert_pmap(rbuf_tmp, src, m_format);
                pmap_tmp.Draw(displayGraphics);

                throw new System.NotImplementedException();
            }
        }
Esempio n. 55
0
 public void CopyFrom(RasterBuffer src)
 {
     CopyFrom(src, new RectI(0, 0, (int)src.Width(), (int)src.Height()), 0, 0);
 }
        public bool load_pmap(string fn, uint idx, RasterBuffer dst)
        {
            PixelMap pmap_tmp = new PixelMap();
            if (!pmap_tmp.load_from_bmp(fn)) return false;

            RasterBuffer rbuf_tmp = new RasterBuffer();
            unsafe
            {
                rbuf_tmp.Attach(pmap_tmp.buf(),
                                pmap_tmp.Width(),
                                pmap_tmp.Height(),
                                m_app.FlipY() ?
                                  pmap_tmp.stride() :
                                 -pmap_tmp.stride(),
                                 pmap_tmp.bpp());

                m_pmap_img[idx] = new PixelMap();
                m_pmap_img[idx].Create(pmap_tmp.Width(), pmap_tmp.Height(),
                    PlatformSupportAbstract.GetBitDepthForPixelFormat(m_format),
                    0);

                dst.Attach(m_pmap_img[idx].buf(),
                    m_pmap_img[idx].Width(),
                    m_pmap_img[idx].Height(),
                    m_app.FlipY() ?
                    m_pmap_img[idx].stride() :
                    -m_pmap_img[idx].stride(), m_pmap_img[idx].bpp());

                switch (m_format)
                {
                    case PlatformSupportAbstract.PixelFormats.Bgr24:
                        switch (pmap_tmp.bpp())
                        {
                            case 24:
                                unsafe
                                {
                                    for (uint y = 0; y < rbuf_tmp.Height(); y++)
                                    {
                                        byte* sourceBuffer = rbuf_tmp.GetPixelPointer((int)rbuf_tmp.Height() - (int)y - 1);
                                        byte* destBuffer = dst.GetPixelPointer((int)y);
                                        for (uint x = 0; x < rbuf_tmp.Width(); x++)
                                        {
                                            *destBuffer++ = sourceBuffer[0];
                                            *destBuffer++ = sourceBuffer[1];
                                            *destBuffer++ = sourceBuffer[2];
                                            sourceBuffer += 3;
                                        }
                                    }
                                }
                                break;

                            default:
                                throw new System.NotImplementedException();
                        }
                        break;

                    case PlatformSupportAbstract.PixelFormats.Rgb24:
                        switch (pmap_tmp.bpp())
                        {
                            //                 case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb24()); break;
                            case 24:

                                //color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgba32());
                                unsafe
                                {
                                    for (uint y = 0; y < rbuf_tmp.Height(); y++)
                                    {
                                        byte* sourceBuffer = rbuf_tmp.GetPixelPointer((int)rbuf_tmp.Height() - (int)y - 1);
                                        byte* destBuffer = dst.GetPixelPointer((int)y);
                                        for (uint x = 0; x < rbuf_tmp.Width(); x++)
                                        {
                                            *destBuffer++ = sourceBuffer[2];
                                            *destBuffer++ = sourceBuffer[1];
                                            *destBuffer++ = sourceBuffer[0];
                                            sourceBuffer += 3;
                                        }
                                    }
                                }
                                break;

                            //                 case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgb24()); break;
                            default:
                                throw new System.NotImplementedException();
                        }
                        break;

                    case PlatformSupportAbstract.PixelFormats.Bgra32:
                        switch (pmap_tmp.bpp())
                        {
                            case 24:
                                unsafe
                                {
                                    for (uint y = 0; y < rbuf_tmp.Height(); y++)
                                    {
                                        byte* sourceBuffer = rbuf_tmp.GetPixelPointer((int)rbuf_tmp.Height() - (int)y - 1);
                                        byte* destBuffer = dst.GetPixelPointer((int)y);
                                        for (uint x = 0; x < rbuf_tmp.Width(); x++)
                                        {
                                            *destBuffer++ = sourceBuffer[0];
                                            *destBuffer++ = sourceBuffer[1];
                                            *destBuffer++ = sourceBuffer[2];
                                            *destBuffer++ = 255;
                                            sourceBuffer += 3;
                                        }
                                    }
                                }
                                break;
                        }
                        break;

                    case PlatformSupportAbstract.PixelFormats.Rgba32:
                        switch (pmap_tmp.bpp())
                        {
                            //                 case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgba32()); break;
                            case 24:

                                //color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgba32());
                                unsafe
                                {
                                    for (uint y = 0; y < rbuf_tmp.Height(); y++)
                                    {
                                        byte* sourceBuffer = rbuf_tmp.GetPixelPointer((int)rbuf_tmp.Height() - (int)y - 1);
                                        byte* destBuffer = dst.GetPixelPointer((int)y);
                                        for (uint x = 0; x < rbuf_tmp.Width(); x++)
                                        {
                                            *destBuffer++ = sourceBuffer[2];
                                            *destBuffer++ = sourceBuffer[1];
                                            *destBuffer++ = sourceBuffer[0];
                                            *destBuffer++ = 255;
                                            sourceBuffer += 3;
                                        }
                                    }
                                }
                                break;

                            //                 case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgba32()); break;
                            default:
                                throw new System.NotImplementedException();
                        }
                        break;

                    default:
                        throw new System.NotImplementedException();
                }
            }

            return true;
        }
Esempio n. 57
0
        public void CopyFrom(RasterBuffer src,
					   RectI rect_src_ptr,
					   int dx,
					   int dy)
        {
            RectI rsrc = new RectI(rect_src_ptr.x1, rect_src_ptr.y1, rect_src_ptr.x2 + 1, rect_src_ptr.y2 + 1);

            // Version with xdst, ydst (absolute positioning)
            //RectI rdst(xdst, ydst, xdst + rsrc.x2 - rsrc.x1, ydst + rsrc.y2 - rsrc.y1);

            // Version with dx, dy (relative positioning)
            RectI rdst = new RectI(rsrc.x1 + dx, rsrc.y1 + dy, rsrc.x2 + dx, rsrc.y2 + dy);

            RectI rc = ClipRectangleArea(ref rdst, ref rsrc, (int)src.Width(), (int)src.Height());

            if (rc.x2 > 0)
            {
                int incy = 1;
                if (rdst.y1 > rsrc.y1)
                {
                    rsrc.y1 += rc.y2 - 1;
                    rdst.y1 += rc.y2 - 1;
                    incy = -1;
                }
                while (rc.y2 > 0)
                {
                    base.CopyFrom(src,
                                     rdst.x1, rdst.y1,
                                     rsrc.x1, rsrc.y1,
                                     (uint)rc.x2);
                    rdst.y1 += incy;
                    rsrc.y1 += incy;
                    --rc.y2;
                }
            }
        }
 public bool save_pmap(string fn, uint idx, RasterBuffer src)
 {
     return true;
 }
Esempio n. 59
0
 ///<summary>
 ///</summary>
 ///<param name="rbuf"></param>
 public void Attach(RasterBuffer rbuf)
 {
     _rasterBuffer = rbuf;
 }
        private static void convert_pmap(RasterBuffer dst,
								 RasterBuffer src,
								 PlatformSupportAbstract.PixelFormats format)
        {
        }