示例#1
0
 public static IBitmap AddLayer(this IBitmap bitmap, Bytemap layer, int left = 0, int top = 0, bool dispose = false)
 {
     if (layer == null)
     {
         return(bitmap);
     }
     for (int yy = 0; yy < layer.Height; yy++)
     {
         if (top + yy >= bitmap.Height())
         {
             break;
         }
         if (bitmap.OutBoundY(top + yy))
         {
             continue;
         }
         for (int xx = 0; xx < layer.Width; xx++)
         {
             if (left + xx >= bitmap.Width())
             {
                 break;
             }
             if (layer[xx, yy] == 0 || bitmap.OutBoundX(left + xx))
             {
                 continue;
             }
             bitmap.Bitmap[left + xx, top + yy] = layer[xx, yy];
         }
     }
     if (dispose)
     {
         layer.Dispose();
     }
     return(bitmap);
 }
示例#2
0
        public static IBitmap DrawRectangle3D(this IBitmap bitmap, int left = 0, int top = 0, int width = -1, int height = -1, byte colourLight = 15, byte colourDark = 8)
        {
            if (width < 0)
            {
                width = bitmap.Width() - left;
            }
            if (height < 0)
            {
                height = bitmap.Height() - top;
            }
            int ww = (left + width - 1), hh = (top + height - 1);

            for (int yy = top; yy <= hh; yy++)
            {
                if (yy >= bitmap.Height())
                {
                    break;
                }
                if (bitmap.OutBoundY(yy))
                {
                    continue;
                }
                for (int xx = left; xx <= ww; xx++)
                {
                    if (xx >= bitmap.Width())
                    {
                        break;
                    }
                    if (bitmap.OutBoundX(xx))
                    {
                        continue;
                    }
                    if (yy == top || xx == ww)
                    {
                        bitmap.Bitmap[xx, yy] = colourDark;
                    }
                    else if (yy == hh || xx == left)
                    {
                        bitmap.Bitmap[xx, yy] = colourLight;
                    }
                }
            }
            return(bitmap);
        }
示例#3
0
 public static IBitmap Tile(this IBitmap bitmap, Bytemap layer, int left = 0, int top = 0, int width = -1, int height = -1)
 {
     if (layer == null)
     {
         return(bitmap);
     }
     if (width == -1)
     {
         width = bitmap.Width() - left;
     }
     if (height == -1)
     {
         height = bitmap.Height() - top;
     }
     for (int yy = 0; yy < height; yy++)
     {
         if (top + yy >= bitmap.Height())
         {
             break;
         }
         if (bitmap.OutBoundY(top + yy))
         {
             continue;
         }
         for (int xx = 0; xx < width; xx++)
         {
             if (left + xx >= bitmap.Width())
             {
                 break;
             }
             if (layer[xx % layer.Width, yy % layer.Height] == 0 || bitmap.OutBoundX(left + xx))
             {
                 continue;
             }
             bitmap.Bitmap[left + xx, top + yy] = layer[xx % layer.Width, yy % layer.Height];
         }
     }
     return(bitmap);
 }