示例#1
0
        public static void artwork_elements_scale(artwork_element ae, int width, int height)
{
            throw new Exception();
        }
示例#2
0
        public static artwork artwork_create(artwork_element[] ae, int start_pen, int max_pens)
        {
            artwork a;
            osd_bitmap circle;
            int pen;

            if ((a = allocate_artwork_mem(Machine.scrbitmap.width, Machine.scrbitmap.height)) == null)
                return null;

            a.start_pen = start_pen;

            a.orig_palette = new byte[256 * 3];

            a.transparency = new byte[256];

            a.num_pens_used = 0;
            a.num_pens_trans = 0;
            int aei = 0;
            while (aei < ae.Length && ae[aei].box.min_x >= 0)
            {
                /* look if the color is already in the palette */
                pen = 0;
                while ((pen < a.num_pens_used) &&
                       ((ae[aei].red != a.orig_palette[3 * pen]) ||
                        (ae[aei].green != a.orig_palette[3 * pen + 1]) ||
                        (ae[aei].blue != a.orig_palette[3 * pen + 2]) ||
                        ((ae[aei].alpha < 255) && (ae[aei].alpha != a.transparency[pen]))))
                    pen++;

                if (pen == a.num_pens_used)
                {
                    a.orig_palette[3 * pen] = ae[aei].red;
                    a.orig_palette[3 * pen + 1] = ae[aei].green;
                    a.orig_palette[3 * pen + 2] = ae[aei].blue;
                    a.num_pens_used++;
                    if (ae[aei].alpha < 255)
                    {
                        a.transparency[pen] = ae[aei].alpha;
                        a.num_pens_trans++;
                    }
                }

                if (ae[aei].box.max_y == -1) /* circle */
                {
                    int r = ae[aei].box.max_x;

                    if ((circle = create_circle(r, pen)) != null)
                    {
                        copybitmap(a.orig_artwork, circle, false, false,
                                   ae[aei].box.min_x - r,
                                   ae[aei].box.min_y - r,
                                   null, TRANSPARENCY_PEN, 255);
                        osd_free_bitmap(circle);
                    }
                }
                else
                    fillbitmap(a.orig_artwork, pen, ae[aei].box);
                aei++;
            }

            /* Make sure we don't have too many colors */
            if (a.num_pens_used > max_pens)
            {
                printf("Too many colors in overlay.\n");
                printf("Colors found: %d  Max Allowed: %d\n", a.num_pens_used, max_pens);
                artwork_free(ref a);
                return null;
            }

            /* If the game uses dynamic colors, we assume that it's safe
               to init the palette and remap the colors now */
            if ((Machine.drv.video_attributes & VIDEO_MODIFIES_PALETTE) != 0)
                backdrop_set_palette(a, a.orig_palette);

            return a;
        }