Example #1
0
 protected void DrawImageInitialize(int x, int y, int width, int height, BytesPerPixel bytesPerPixel) {
     BasicTypeSerializer.Put(SendContext, (byte)Command.DrawImageInitialize);
     BasicTypeSerializer.Put(SendContext, (ushort)x);
     BasicTypeSerializer.Put(SendContext, (ushort)y);
     BasicTypeSerializer.Put(SendContext, (ushort)width);
     BasicTypeSerializer.Put(SendContext, (ushort)height);
     BasicTypeSerializer.Put(SendContext, (ushort)bytesPerPixel);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TileMaskCollection"/> class.
 /// </summary>
 public TileMaskCollection(BytesPerPixel bytesPerColor)
 {
     tiles          = new List <TileMask>();
     bitmaps        = new ConcurrentDictionary <Zoom, DirtyBitmap>();
     BytesPerColor  = bytesPerColor;
     Left           = -1;
     Top            = -1;
     Right          = -1;
     Bottom         = -1;
     RequireRefresh = true;
 }
Example #3
0
        public override void Initialize(int width, int height, BytesPerPixel bpp)
        {
            if (Buffer != null)
            {
                Buffer.Dispose();
            }

            Buffer = HardwareAcceleratorManager.GPUAccelerator.Allocate <byte>(bpp, width, height);
            Buffer.MemSetToZero();
            requireCopyTo = true;
            base.Initialize(width, height, bpp);
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Layer"/> class.
 /// </summary>
 public Layer(BytesPerPixel bytesPerColor)
 {
     BytesPerColor = bytesPerColor;
     tiles         = new Dictionary <PositionKey, List <TileMask> >();
 }
Example #5
0
        GetTiles <T, K>(T[] palettes, ConcurrentDictionary <TileKey, int> tiles, ConcurrentDictionary <TileKey, TileKey> alltiles, Int32[,] bp, int tileWidth, int tileHeight) where T : ColorPaletteDisguise, new()
            where K : IndexedBitmapBufferDisguise, new()
        {
            BytesPerPixel bpp = palettes[0].RealObject.BytesPerColor;
            ConcurrentDictionary <Int32, int> colDic;
            ConcurrentDictionary <TileKey, K> curtileQ;
            int rm;
            int flip;
            ConcurrentDictionary <TileKey, int> cloneTiles = new ConcurrentDictionary <TileKey, int>();
            ConcurrentQueue <Tuple <TileKey, bool, bool, K> > results;

            Parallel.ForEach(tiles, kvp =>
            {
                cloneTiles.TryAdd(kvp.Key, 0);
            });

            ConcurrentDictionary <ColorPaletteIndex, List <Tuple <TileKey, bool, bool, K> > > ret = new ConcurrentDictionary <ColorPaletteIndex, List <Tuple <TileKey, bool, bool, K> > >();

            using (MemoryBuffer2D <int> bpbuff = HardwareAcceleratorManager.GPUAccelerator.Allocate <int>(bp.GetLength(0), bp.GetLength(1)))
            {
                bpbuff.CopyFrom(bp, Index2.Zero, Index2.Zero, bpbuff.Extent);
                for (int x = 0; x < palettes.Length; x++)
                {
                    colDic   = palettes[x].RealObject.ToColorDictionary();
                    curtileQ = new ConcurrentDictionary <TileKey, K>();
                    results  = new ConcurrentQueue <Tuple <TileKey, bool, bool, K> >();
                    foreach (var kvp in cloneTiles)
                    {
                        int  curpX = 0;
                        int  curpY = 0;
                        int  offX  = kvp.Key.X * tileWidth;
                        int  offY  = kvp.Key.Y * tileHeight;
                        int  c;
                        bool add = true;
                        K    curTile;
                        for (int i = 0; i < tileWidth && add; i++)
                        {
                            curpX = i + offX;
                            for (int j = 0; j < tileHeight; j++)
                            {
                                curpY = j + offY;
                                c     = bp[curpX, curpY];
                                c     = bpp.ShortColor(c);
                                if (!colDic.ContainsKey(c))
                                {
                                    add = false;
                                    break;
                                }
                            }
                        }
                        if (add)
                        {
                            curTile = IndexedBitmapBufferDisguise.Generate <K>(tileWidth, tileHeight);
                            curTile.RealObject.BuildFromBitmap(bp, colDic, offX, offY);
                            curtileQ.TryAdd(kvp.Key, curTile);
                        }
                    }

                    foreach (var t in curtileQ)
                    {
                        cloneTiles.TryRemove(t.Key, out rm);
                    }

                    foreach (var kvp in alltiles)
                    {
                        if (kvp.Value.X == -1 && curtileQ.ContainsKey(kvp.Key))
                        {
                            results.Enqueue(new Tuple <TileKey, bool, bool, K>(kvp.Key, false, false, curtileQ[kvp.Key]));
                        }
                        else if (curtileQ.ContainsKey(kvp.Value))
                        {
                            flip = TileCheckerKernel.Execute(new Index2(tileWidth, tileHeight), bpbuff,
                                                             new Index2(kvp.Value.X * tileWidth, kvp.Value.Y * tileHeight), new Index2(kvp.Key.X * tileWidth, kvp.Key.Y * tileHeight));
                            if (flip >= 0)
                            {
                                results.Enqueue(new Tuple <TileKey, bool, bool, K>(kvp.Key, (flip & 1) == 1, (flip & 2) == 2, curtileQ[kvp.Value]));
                            }
                        }
                    }

                    ret.TryAdd(palettes[x].RealObject.Index, results.ToList());
                }
            }

            return(ret);
        }
Example #6
0
 public GPUBitmapBuffer(int width, int height, BytesPerPixel bpp) : base(width, height, bpp)
 {
 }
Example #7
0
 public void Initialize(ColorPaletteIndex index, int size, BytesPerPixel bpp)
 {
     RealObject = DressUp(index, size, bpp);
 }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColorPaletteDisguise"/> class.
 /// </summary>
 /// <param name="args">The args.</param>
 protected ColorPaletteDisguise(ColorPaletteIndex index, int size, BytesPerPixel bpp) : base(index, size, bpp)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ColorPalette"/> class.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="size">The size.</param>
 public ColorPalette(ColorPaletteIndex index, int size, BytesPerPixel bpp) : base(index, size, bpp)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TilemapGrid"/> class.
 /// </summary>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="z">The z.</param>
 /// <param name="bgR">The bg r.</param>
 /// <param name="bgG">The bg g.</param>
 /// <param name="bgB">The bg b.</param>
 public TilemapGrid(int width, int height, Zoom z, BytesPerPixel bpp, params byte[] color) : base(width, height, z, bpp, color)
 {
     layers = new List <Layer>();
 }
Example #11
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CameraDev.Length != 0)
            {
                hash ^= CameraDev.GetHashCode();
            }
            if (FrameId.Length != 0)
            {
                hash ^= FrameId.GetHashCode();
            }
            if (PixelFormat.Length != 0)
            {
                hash ^= PixelFormat.GetHashCode();
            }
            if (IoMethod != 0)
            {
                hash ^= IoMethod.GetHashCode();
            }
            if (Width != 0)
            {
                hash ^= Width.GetHashCode();
            }
            if (Height != 0)
            {
                hash ^= Height.GetHashCode();
            }
            if (FrameRate != 0)
            {
                hash ^= FrameRate.GetHashCode();
            }
            if (Monochrome != false)
            {
                hash ^= Monochrome.GetHashCode();
            }
            if (Brightness != 0)
            {
                hash ^= Brightness.GetHashCode();
            }
            if (Contrast != 0)
            {
                hash ^= Contrast.GetHashCode();
            }
            if (Saturation != 0)
            {
                hash ^= Saturation.GetHashCode();
            }
            if (Sharpness != 0)
            {
                hash ^= Sharpness.GetHashCode();
            }
            if (Gain != 0)
            {
                hash ^= Gain.GetHashCode();
            }
            if (AutoFocus != false)
            {
                hash ^= AutoFocus.GetHashCode();
            }
            if (Focus != 0)
            {
                hash ^= Focus.GetHashCode();
            }
            if (AutoExposure != false)
            {
                hash ^= AutoExposure.GetHashCode();
            }
            if (Exposure != 0)
            {
                hash ^= Exposure.GetHashCode();
            }
            if (AutoWhiteBalance != false)
            {
                hash ^= AutoWhiteBalance.GetHashCode();
            }
            if (WhiteBalance != 0)
            {
                hash ^= WhiteBalance.GetHashCode();
            }
            if (BytesPerPixel != 0)
            {
                hash ^= BytesPerPixel.GetHashCode();
            }
            if (TriggerInternal != 0)
            {
                hash ^= TriggerInternal.GetHashCode();
            }
            if (TriggerFps != 0)
            {
                hash ^= TriggerFps.GetHashCode();
            }
            if (ChannelName.Length != 0)
            {
                hash ^= ChannelName.GetHashCode();
            }
            if (DeviceWaitMs != 0)
            {
                hash ^= DeviceWaitMs.GetHashCode();
            }
            if (SpinRate != 0)
            {
                hash ^= SpinRate.GetHashCode();
            }
            if (OutputType != 0)
            {
                hash ^= OutputType.GetHashCode();
            }
            if (compressConf_ != null)
            {
                hash ^= CompressConf.GetHashCode();
            }
            return(hash);
        }
Example #12
0
 protected void DrawImageInitialize(int x, int y, int width, int height, BytesPerPixel bytesPerPixel)
 {
     BasicTypeSerializer.Put(SendContext, (byte)Command.DrawImageInitialize);
     BasicTypeSerializer.Put(SendContext, (ushort)x);
     BasicTypeSerializer.Put(SendContext, (ushort)y);
     BasicTypeSerializer.Put(SendContext, (ushort)width);
     BasicTypeSerializer.Put(SendContext, (ushort)height);
     BasicTypeSerializer.Put(SendContext, (ushort)bytesPerPixel);
 }
Example #13
0
 /*
  * public override void DrawGrid(int zoom, int cellsize, int type, byte colorR, byte colorG, byte colorB)
  * {
  *  int zs = zoom * cellsize;
  *  int lateralCount = Width / zs;
  *  if (Width % zs != 0) lateralCount++;
  *  int verticalCount = Height / zs;
  *  if (Height % zs != 0) verticalCount++;
  *  int z2 = zoom << 1;
  *  switch (type)
  *  {
  *      case 0:
  *          _ = Parallel.For(1, verticalCount, j =>
  *          {
  *              int jw = j * zs * Width;
  *              _ = Parallel.For(0, Width, i =>
  *              {
  *                  int ind = (jw + i) * 3;
  *                  pixels[ind] = colorR;
  *                  pixels[ind + 1] = colorG;
  *                  pixels[ind + 2] = colorB;
  *              });
  *          });
  *
  *          _ = Parallel.For(1, Height, j =>
  *          {
  *              int jw = j * Width;
  *              _ = Parallel.For(1, lateralCount, i =>
  *              {
  *                  int ind = (jw + (i * zs)) * 3;
  *                  pixels[ind] = colorR;
  *                  pixels[ind + 1] = colorG;
  *                  pixels[ind + 2] = colorB;
  *              });
  *          });
  *          break;
  *
  *      case 1:
  *          int wmz = Width - zoom;
  *          _ = Parallel.For(1, verticalCount, j =>
  *          {
  *              int jw = j * zs * Width;
  *              _ = Parallel.For(0, wmz, i =>
  *              {
  *                  int drawer = ((i / z2) % 2);
  *                  if (drawer == 1 || i % z2 == 0)
  *                  {
  *                      int ind = (jw + i + zoom) * 3;
  *                      pixels[ind] = colorR;
  *                      pixels[ind + 1] = colorG;
  *                      pixels[ind + 2] = colorB;
  *                  }
  *              });
  *          });
  *
  *          _ = Parallel.For(0, Height - zoom, j =>
  *          {
  *              int drawer = (j / z2) % 2;
  *              if (drawer == 1 || j % z2 == 0)
  *              {
  *                  int jw = (j + zoom) * Width;
  *                  _ = Parallel.For(1, lateralCount, i =>
  *                  {
  *                      int ind = (jw + (i * zs)) * 3;
  *                      pixels[ind] = colorR;
  *                      pixels[ind + 1] = colorG;
  *                      pixels[ind + 2] = colorB;
  *                  });
  *              }
  *          });
  *          break;
  *
  *      default:
  *          int dist = Math.Min(4, z2);
  *          if (dist == 1) dist = 2;
  *          _ = Parallel.For(1, verticalCount, j =>
  *          {
  *              int jw = j * zs * Width;
  *              _ = Parallel.For(0, Width, i =>
  *              {
  *                  if ((i % dist) == 0)
  *                  {
  *                      int ind = (jw + i) * 3;
  *                      pixels[ind] = colorR;
  *                      pixels[ind + 1] = colorG;
  *                      pixels[ind + 2] = colorB;
  *                  }
  *              });
  *          });
  *
  *          _ = Parallel.For(1, Height, j =>
  *          {
  *              int jw = j * Width;
  *              if ((j % dist) == 0)
  *                  _ = Parallel.For(1, lateralCount, i =>
  *                  {
  *                      int ind = (jw + (i * zs)) * 3;
  *                      pixels[ind] = colorR;
  *                      pixels[ind + 1] = colorG;
  *                      pixels[ind + 2] = colorB;
  *                  });
  *          });
  *          break;
  *  }
  * }
  *
  * public override void DrawLine(int x1, int y1, int x2, int y2, byte colorR, byte colorG, byte colorB)
  * {
  *  int dX = x2 - x1;
  *
  *  int dY = y2 - y1;
  *
  *  if (dY == 0 && dX == 0) return;
  *
  *  if (dX == 0)
  *  {
  *      _ = Parallel.For(y1, Math.Min(y2 + 1, Height), j =>
  *      {
  *          int ind = ((j * Width) + x1) * 3;
  *          pixels[ind] = colorR;
  *          pixels[ind + 1] = colorG;
  *          pixels[ind + 2] = colorB;
  *      });
  *  }
  *  else if (dY == 0)
  *  {
  *      int jw = y1 * Width;
  *      _ = Parallel.For(x1, Math.Min(x2 + 1, Width), i =>
  *      {
  *          int ind = (jw + i) * 3;
  *          pixels[ind] = colorR;
  *          pixels[ind + 1] = colorG;
  *          pixels[ind + 2] = colorB;
  *      });
  *  }
  *  else
  *  {
  *      float props = dY / (float)dX;
  *
  *      if (Math.Abs(dX) >= Math.Abs(dY))
  *      {
  *          int minX = Math.Min(x2, x1);
  *          int maxX = Math.Max(x2, x1);
  *          _ = Parallel.For(minX, maxX + 1, i =>
  *          {
  *              float y = (((i - x1) * props) + y1);
  *              int ind = ((int)(Math.Round(y, 0) * Width) + i) * 3;
  *              pixels[ind] = colorR;
  *              pixels[ind + 1] = colorG;
  *              pixels[ind + 2] = colorB;
  *          });
  *      }
  *      else
  *      {
  *          int minY = Math.Min(y2, y1);
  *          int maxY = Math.Max(y2, y1);
  *          _ = Parallel.For(minY, maxY + 1, i =>
  *          {
  *              float x = ((i - y1) / props) + x1;
  *              int ind = ((int)Math.Round(x, 0) + i * Width) * 3;
  *              pixels[ind] = colorR;
  *              pixels[ind + 1] = colorG;
  *              pixels[ind + 2] = colorB;
  *          });
  *      }
  *  }
  * }*/
 public override void Initialize(int width, int height, BytesPerPixel bpp)
 {
     base.Initialize(width, height, bpp);
     pixels = new byte[Length];
 }