Beispiel #1
0
        public void DrawBitmap(UBitmap bitmap, float opacity, UInterp interp, Rectangle source, Rectangle destination)
        {
            var rd = bitmap.Retreive <OTKDraw>(() =>
            {
                var bd    = bitmap.bitmapData ?? System.IO.File.ReadAllBytes(bitmap.bitmapFile);
                var dt    = new distex();
                var sz    = LoadBitmapIntoTexture(dt.tex, bd);
                dt.width  = sz.Width;
                dt.height = sz.Height;
                return(dt);
            }) as distex;

            int st = rel.renderData.sofwareBuffer.Count;

            bufferTexRect(destination,
                          new Rectangle(
                              source.left / rd.width,
                              source.top / rd.height,
                              source.width / rd.width,
                              source.height / rd.height
                              )
                          );
            int cnt = rel.renderData.sofwareBuffer.Count - st;

            rel.renderData.bufferInfo.Add(new RenderInfo(st, cnt, ArrayData.Vertex | ArrayData.Texture | ArrayData.Color, PrimitiveType.Quads, rd.tex));

            //var bm = SaveTextureIntoBitmap(rd.tex, rd.width, rd.height);
            //bm.Save("test.png",sdg.Imaging.ImageFormat.Png);
            //System.Diagnostics.Process.Start("test.png");
        }
Beispiel #2
0
        CompositingQuality Translate(UInterp ui)
        {
            switch (ui)
            {
            default:
            case UInterp.Linear: return(CompositingQuality.AssumeLinear);

            case UInterp.Nearest: return(CompositingQuality.HighSpeed);
            }
        }
Beispiel #3
0
        BitmapInterpolationMode Translate(UInterp interp)
        {
            switch (interp)
            {
            case UInterp.Linear: return(BitmapInterpolationMode.Linear);

            case UInterp.Nearest: return(BitmapInterpolationMode.NearestNeighbor);

            default: throw new NotImplementedException();
            }
        }
Beispiel #4
0
        public void DrawBitmap(UBitmap bitmap, float opacity, UInterp interp, NoForms.Common.Rectangle source, NoForms.Common.Rectangle destination)
        {
            var bm = CreateBitmap(bitmap);

            if (opacity < 1.0f)
            {
                for (int x = 0; x < bm.Width; x++)
                {
                    for (int y = 0; y < bm.Height; y++)
                    {
                        bm.SetPixel(x, y, System.Drawing.Color.FromArgb((int)(opacity * 255), bm.GetPixel(x, y)));
                    }
                }
            }

            var previousInterp = realRenderer.graphics.CompositingQuality;

            realRenderer.graphics.CompositingQuality = Translate(interp);
            realRenderer.graphics.DrawImage(bm, SDGTr.trF(destination), SDGTr.trF(source), GraphicsUnit.Pixel);
            realRenderer.graphics.CompositingQuality = previousInterp;
        }
Beispiel #5
0
 public void DrawBitmap(UBitmap bitmap, float opacity, UInterp interp, Rectangle source, Rectangle destination)
 {
     realRenderer.renderTarget.DrawBitmap(CreateBitmap(bitmap), D2DTr.tr(destination), opacity, Translate(interp), D2DTr.tr(source));
 }