Esempio n. 1
0
        //-------------------------------------------------
        //  render_triangle - render a triangle that
        //  is used for up/down arrows and left/right
        //  indicators
        //-------------------------------------------------
        static void render_triangle(bitmap_argb32 dest, bitmap_argb32 source, rectangle sbounds, object param)  //void *param)
        {
            int halfwidth = dest.width() / 2;
            int height = dest.height();
            int x, y;

            // start with all-transparent
            dest.fill(new rgb_t(0x00, 0x00, 0x00, 0x00));

            // render from the tip to the bottom
            for (y = 0; y < height; y++)
            {
                int linewidth = (y * (halfwidth - 1) + (height / 2)) * 255 * 2 / height;
                //uint32_t *target = &dest.pix32(y, halfwidth);
                RawBuffer targetBuf;
                UInt32    targetOffset = dest.pix32(out targetBuf, y, halfwidth);

                // don't antialias if height < 12
                if (dest.height() < 12)
                {
                    int pixels = (linewidth + 254) / 255;
                    if (pixels % 2 == 0)
                    {
                        pixels++;
                    }
                    linewidth = pixels * 255;
                }

                // loop while we still have data to generate
                for (x = 0; linewidth > 0; x++)
                {
                    int dalpha;

                    // first column we only consume one pixel
                    if (x == 0)
                    {
                        dalpha = Math.Min(0xff, linewidth);
                        targetBuf.set_uint32((int)targetOffset + x, new rgb_t((byte)dalpha, 0xff, 0xff, 0xff));  //target[x] = new rgb_t(dalpha, 0xff, 0xff, 0xff);
                    }

                    // remaining columns consume two pixels, one on each side
                    else
                    {
                        dalpha = Math.Min(0x1fe, linewidth);
                        targetBuf.set_uint32((int)targetOffset + x, new rgb_t((byte)(dalpha / 2), 0xff, 0xff, 0xff));  //target[x] = target[-x] = new rgb_t((byte)(dalpha / 2), 0xff, 0xff, 0xff);
                        targetBuf.set_uint32((int)targetOffset + (-x), new rgb_t((byte)(dalpha / 2), 0xff, 0xff, 0xff));
                    }

                    // account for the weight we consumed */
                    linewidth -= dalpha;
                }
            }
        }
Esempio n. 2
0
        //-------------------------------------------------
        //  render_triangle - render a triangle that
        //  is used for up/down arrows and left/right
        //  indicators
        //-------------------------------------------------
        static void render_triangle(bitmap_argb32 dest, bitmap_argb32 source, rectangle sbounds, object param)  //void *param)
        {
            int halfwidth = dest.width() / 2;
            int height    = dest.height();

            // start with all-transparent
            dest.fill(new rgb_t(0x00, 0x00, 0x00, 0x00));

            // render from the tip to the bottom
            for (int y = 0; y < height; y++)
            {
                int        linewidth = (y * (halfwidth - 1) + (height / 2)) * 255 * 2 / height;
                PointerU32 target    = dest.pix(y, halfwidth); //uint32_t *const target = &dest.pix(y, halfwidth);

                // don't antialias if height < 12
                if (dest.height() < 12)
                {
                    int pixels = (linewidth + 254) / 255;
                    if (pixels % 2 == 0)
                    {
                        pixels++;
                    }
                    linewidth = pixels * 255;
                }

                // loop while we still have data to generate
                for (int x = 0; linewidth > 0; x++)
                {
                    int dalpha;

                    if (x == 0)
                    {
                        // first column we only consume one pixel
                        dalpha    = std.min(0xff, linewidth);
                        target[x] = new rgb_t((uint8_t)dalpha, 0xff, 0xff, 0xff);  //target[x] = rgb_t(dalpha, 0xff, 0xff, 0xff);
                    }
                    else
                    {
                        // remaining columns consume two pixels, one on each side
                        dalpha    = std.min(0x1fe, linewidth);
                        target[x] = target[-x] = new rgb_t((uint8_t)(dalpha / 2), 0xff, 0xff, 0xff);  //target[x] = target[-x] = rgb_t(dalpha / 2, 0xff, 0xff, 0xff);
                    }

                    // account for the weight we consumed
                    linewidth -= dalpha;
                }
            }
        }