Example #1
0
 public ObscuredWipeTransition(Frame obscuring_frame, DMDBlendMode composite_op, ObscuredWipeTransitionDirection direction = ObscuredWipeTransitionDirection.North)
 {
     this.composite_op       = composite_op;
     this.direction          = direction;
     this.progress_per_frame = 1.0 / 15.0;
     this.obs_frame          = obscuring_frame;
 }
 public ObscuredWipeTransition(Frame obscuring_frame, DMDBlendMode composite_op, ObscuredWipeTransitionDirection direction = ObscuredWipeTransitionDirection.North)
 {
     this.composite_op = composite_op;
     this.direction = direction;
     this.progress_per_frame = 1.0 / 15.0;
     this.obs_frame = obscuring_frame;
 }
Example #3
0
 public static void copy_rect(DMDBuffer dst, int dst_x, int dst_y, DMDBuffer src, int src_x, int src_y, int width, int height, DMDBlendMode mode = DMDBlendMode.DMDBlendModeCopy)
 {
     src.copy_to_rect(dst, dst_x, dst_y, src_x, src_y, width, height, mode);
 }
Example #4
0
 public void copy_to_rect(DMDBuffer dst, int dst_x, int dst_y, int src_x, int src_y, int width, int height, DMDBlendMode mode = DMDBlendMode.DMDBlendModeCopy)
 {
     DMDRect srcRect = DMDGlobals.DMDRectMake(src_x, src_y, width, height);
     DMDPoint dstPoint = DMDGlobals.DMDPointMake(dst_x, dst_y);
     DMDGlobals.DMDFrameCopyRect(ref frame, srcRect, ref dst.frame, dstPoint, mode);
 }
Example #5
0
 public static void copy_rect(DMDBuffer dst, int dst_x, int dst_y, DMDBuffer src, int src_x, int src_y, int width, int height, DMDBlendMode mode = DMDBlendMode.DMDBlendModeCopy)
 {
     src.copy_to_rect(dst, dst_x, dst_y, src_x, src_y, width, height, mode);
 }
Example #6
0
        public static void DMDFrameCopyRect(ref DMDFrame src, DMDRect srcRect, ref DMDFrame dst, DMDPoint dstPoint, DMDBlendMode blendMode)
        {
            //double startTime = tools.Time.GetTime();
            srcRect = DMDRectIntersection(DMDFrameGetBounds(ref src), srcRect);
            DMDRect dstRect = DMDRectIntersection(DMDFrameGetBounds(ref dst),
                                                  DMDRectMake(dstPoint.x, dstPoint.y, srcRect.size.width, srcRect.size.height));

            if (srcRect.size.width == 0 || srcRect.size.height == 0)
            {
                return; /* Nothing to do */
            }
            int  width = dstRect.size.width;
            int  height = dstRect.size.height;
            int  x, y;
            byte dot;

            if (blendMode == DMDBlendMode.DMDBlendModeCopy)
            {
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        dot = DMDFrameGetDot(ref src, srcRect.origin.x + x, srcRect.origin.y + y);
                        DMDFrameSetDot(ref dst, dstRect.origin.x + x, dstRect.origin.y + y,
                                       dot);
                    }
                }
            }
            else if (blendMode == DMDBlendMode.DMDBlendModeAdd)
            {
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        byte srcDot = DMDFrameGetDot(ref src, srcRect.origin.x, srcRect.origin.y + y);
                        byte dstDot = DMDFrameGetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y);
                        DMDFrameSetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y, (byte)Math.Min(srcDot + dstDot, 0xF));
                    }
                }
            }
            else if (blendMode == DMDBlendMode.DMDBlendModeBlackSource)
            {
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        byte srcDot = DMDFrameGetDot(ref src, srcRect.origin.x, srcRect.origin.y + y);
                        byte dstDot = DMDFrameGetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y);
                        // Only write dots into black dots
                        if ((srcDot & 0xf) != 0)
                        {
                            DMDFrameSetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y, (byte)((dstDot & 0xf0) | (srcDot & 0xf)));
                        }
                    }
                }
            }
            else if (blendMode == DMDBlendMode.DMDBlendModeSubtract)
            {
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        byte srcDot = DMDFrameGetDot(ref src, srcRect.origin.x, srcRect.origin.y + y);
                        byte dstDot = DMDFrameGetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y);
                        DMDFrameSetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y, (byte)Math.Max(srcDot + dstDot, 0xF));
                    }
                }
            }
            else if (blendMode == DMDBlendMode.DMDBlendModeAlpha)
            {
                byte[] alphaMap = DMDGetAlphaMap();

                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        byte srcDot = DMDFrameGetDot(ref src, srcRect.origin.x, srcRect.origin.y + y);
                        byte dstDot = DMDFrameGetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y);
                        byte v      = alphaMap[srcDot * 256 + (dstDot | 0xf0)];
                        DMDFrameSetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y, (byte)((dstDot & 0xf0) | (v & 0x0f)));
                    }
                }
            }
            else if (blendMode == DMDBlendMode.DMDBlendModeAlphaBoth)
            {
                byte[] alphaMap = DMDGetAlphaMap();
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        byte dstValue = DMDFrameGetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y);
                        byte srcValue = DMDFrameGetDot(ref src, srcRect.origin.x, srcRect.origin.y + y);

                        DMDFrameSetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y, alphaMap[srcValue * 256 + dstValue]);
                    }
                }
            }
            //Console.WriteLine("     DMDFrameCopyRect total time: {0}ms", (tools.Time.GetTime() - startTime) * 1000);
        }
Example #7
0
        public void copy_to_rect(DMDBuffer dst, int dst_x, int dst_y, int src_x, int src_y, int width, int height, DMDBlendMode mode = DMDBlendMode.DMDBlendModeCopy)
        {
            DMDRect  srcRect  = DMDGlobals.DMDRectMake(src_x, src_y, width, height);
            DMDPoint dstPoint = DMDGlobals.DMDPointMake(dst_x, dst_y);

            DMDGlobals.DMDFrameCopyRect(ref frame, srcRect, ref dst.frame, dstPoint, mode);
        }
Example #8
0
        public static void DMDFrameCopyRect(ref DMDFrame src, DMDRect srcRect, ref DMDFrame dst, DMDPoint dstPoint, DMDBlendMode blendMode)
        {
            //double startTime = tools.Time.GetTime();
            srcRect = DMDRectIntersection(DMDFrameGetBounds(ref src), srcRect);
            DMDRect dstRect = DMDRectIntersection(DMDFrameGetBounds(ref dst),
                                DMDRectMake(dstPoint.x, dstPoint.y, srcRect.size.width, srcRect.size.height));

            if (srcRect.size.width == 0 || srcRect.size.height == 0)
                return; /* Nothing to do */

            int width = dstRect.size.width;
            int height = dstRect.size.height;
            int x, y;
            byte dot;

            if (blendMode == DMDBlendMode.DMDBlendModeCopy)
            {
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        dot = DMDFrameGetDot(ref src, srcRect.origin.x + x, srcRect.origin.y + y);
                        DMDFrameSetDot(ref dst, dstRect.origin.x + x, dstRect.origin.y + y,
                            dot);
                    }
                }
            }
            else if (blendMode == DMDBlendMode.DMDBlendModeAdd)
            {
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        byte srcDot = DMDFrameGetDot(ref src, srcRect.origin.x, srcRect.origin.y + y);
                        byte dstDot = DMDFrameGetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y);
                        DMDFrameSetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y, (byte)Math.Min(srcDot + dstDot, 0xF));
                    }
                }
            }
            else if (blendMode == DMDBlendMode.DMDBlendModeBlackSource)
            {
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        byte srcDot = DMDFrameGetDot(ref src, srcRect.origin.x, srcRect.origin.y + y);
                        byte dstDot = DMDFrameGetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y);
                        // Only write dots into black dots
                        if ((srcDot & 0xf) != 0)
                        {
                            DMDFrameSetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y, (byte)((dstDot & 0xf0) | (srcDot & 0xf)));
                        }
                    }
                }
            }
            else if (blendMode == DMDBlendMode.DMDBlendModeSubtract)
            {
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        byte srcDot = DMDFrameGetDot(ref src, srcRect.origin.x, srcRect.origin.y + y);
                        byte dstDot = DMDFrameGetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y);
                        DMDFrameSetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y, (byte)Math.Max(srcDot + dstDot, 0xF));
                    }
                }
            }
            else if (blendMode == DMDBlendMode.DMDBlendModeAlpha)
            {
                byte[] alphaMap = DMDGetAlphaMap();

                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        byte srcDot = DMDFrameGetDot(ref src, srcRect.origin.x, srcRect.origin.y + y);
                        byte dstDot = DMDFrameGetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y);
                        byte v = alphaMap[srcDot * 256 + (dstDot | 0xf0)];
                        DMDFrameSetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y, (byte)((dstDot & 0xf0) | (v & 0x0f)));
                    }
                }
            }
            else if (blendMode == DMDBlendMode.DMDBlendModeAlphaBoth)
            {
                byte[] alphaMap = DMDGetAlphaMap();
                for (y = 0; y < height; y++)
                {
                    for (x = 0; x < width; x++)
                    {
                        byte dstValue = DMDFrameGetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y);
                        byte srcValue = DMDFrameGetDot(ref src, srcRect.origin.x, srcRect.origin.y + y);

                        DMDFrameSetDot(ref dst, dstRect.origin.x, dstRect.origin.y + y, alphaMap[srcValue * 256 + dstValue]);
                    }
                }
            }
            //Console.WriteLine("     DMDFrameCopyRect total time: {0}ms", (tools.Time.GetTime() - startTime) * 1000);
        }