示例#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");
        }
示例#2
0
 Bitmap CreateNewBitmap(UBitmap b)
 {
     System.Drawing.Bitmap bm;
     if (b.bitmapData != null)
     {
         System.IO.MemoryStream ms = new System.IO.MemoryStream(b.bitmapData);
         bm = new System.Drawing.Bitmap(ms);
     }
     else
     {
         bm = new System.Drawing.Bitmap(b.bitmapFile);
     }
     return(bm);
 }
示例#3
0
        Bitmap CreateNewBitmap(UBitmap b)
        {
            // FIXME arg this class is slow!
            System.Drawing.Bitmap bm;
            if (b.bitmapData != null)
            {
                System.IO.MemoryStream ms = new System.IO.MemoryStream(b.bitmapData);
                bm = new System.Drawing.Bitmap(ms);
            }
            else
            {
                bm = new System.Drawing.Bitmap(b.bitmapFile);
            }
            SharpDXLib.WIC.Bitmap wbm = new SharpDXLib.WIC.Bitmap(wicFact, bm, SharpDXLib.WIC.BitmapAlphaChannelOption.UseAlpha);
            var bmd = Bitmap.FromWicBitmap(realRenderer.renderTarget, wbm);

            realRenderer.renderTarget.Disposed += new EventHandler <EventArgs>((o, e) => b.Invalidate());
            return(bmd);
        }
示例#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;
        }
示例#5
0
 Bitmap CreateBitmap(UBitmap b)
 {
     return(b.Retreive <SDG_RenderElements>(new NoCacheDelegate(() => CreateNewBitmap(b))) as Bitmap);
 }
示例#6
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));
 }
示例#7
0
        public UBitmap GenerateBitmap()
        {
            if (ColorHeights.Count == 0)
                return new UBitmap(1, 1);

            SortColors();

            var maxHeigth = MaxHeight;

            if (maxHeigth == 0)
                return new UBitmap(1, 1);

            var bitmap = new UBitmap(1, maxHeigth);

            ColorHeight prevC = null;

            foreach (var colorHeight in ColorHeights)
            {
                if (prevC == null)
                {
                    prevC = colorHeight;
                    continue;
                }

                if (colorHeight.Heigth == prevC.Heigth)
                    continue;

                for (int i = prevC.Heigth; i < colorHeight.Heigth; i++)
                    bitmap.Map[0, i] =
                        MergeColors(prevC.Color, colorHeight.Color,
                            (1 - (i - prevC.Heigth) / (double)(colorHeight.Heigth - prevC.Heigth)));

                prevC = colorHeight;
            }

            foreach (var colorHeight in ColorHeights)
            {
                if (colorHeight.Heigth > 0)
                    bitmap.Map[0, colorHeight.Heigth - 1] = new UColor(0xff, 0, 0);
            }

            var newBmp = new UBitmap(1, maxHeigth);

            for (int i = 0; i < maxHeigth; i++)
            {
                newBmp[0, i] = bitmap[0, maxHeigth - i - 1];
            }

            return newBmp;
        }