Esempio n. 1
0
        public static artwork artwork_load_size(string filename, int start_pen, int max_pens, int width, int height)
        {
            osd_bitmap picture = null;
            artwork a = null;
            png_info p=new png_info();

            /* If the user turned artwork off, bail */
            if (!options.use_artwork) return null;

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

            a.start_pen = start_pen;

            if (artwork_read_bitmap(filename, ref picture, ref p) == 0)
            {
                artwork_free(ref a);
                return null;
            }

            a.num_pens_used = (int)p.num_palette;
            a.num_pens_trans = (int)p.num_trans;
            a.orig_palette = p.palette;
            a.transparency = p.trans;

            /* 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);
                osd_free_bitmap(picture);
                return null;
            }

            /* Scale the original picture to be the same size as the visible area */
            if ((Machine.orientation & ORIENTATION_SWAP_XY) != 0)
                copybitmapzoom(a.orig_artwork, picture, false, false, 0, 0,
                           null, TRANSPARENCY_NONE, 0,
                           (a.orig_artwork.height << 16) / picture.height,
                           (a.orig_artwork.width << 16) / picture.width);
            else
                copybitmapzoom(a.orig_artwork, picture, false, false, 0, 0,
                           null, TRANSPARENCY_NONE, 0,
                           (a.orig_artwork.width << 16) / picture.width,
                           (a.orig_artwork.height << 16) / picture.height);

            /* 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);

            /* We don't need the original any more */
            osd_free_bitmap(picture);

            return a;
        }
Esempio n. 2
0
        static int artwork_read_bitmap(string file_name, ref osd_bitmap bitmap, ref png_info p)
        {

            uint orientation;
            uint x, y;
            object fp;

            if ((fp = osd_fopen(Machine.gamedrv.name, file_name, OSD_FILETYPE_ARTWORK, 0)) == null)
            {
                printf("Unable to open PNG %s\n", file_name);
                return 0;
            }

            if (png_read_file(fp, p) == 0)
            {
                osd_fclose(fp);
                return 0;
            }
            osd_fclose(fp);

            if (p.bit_depth > 8)
            {
                printf("Unsupported bit depth %i (8 bit max.)\n", p.bit_depth);
                return 0;
            }

            if (p.color_type != 3)
            {
                printf("Unsupported color type %i (has to be 3)\n", p.color_type);
                return 0;
            }
            if (p.interlace_method != 0)
            {
                printf("Interlace unsupported\n");
                return 0;
            }

            /* Convert to 8 bit */
            png_expand_buffer_8bit(p);

            png_delete_unused_colors(p);

            if ((bitmap = osd_create_bitmap((int)p.width, (int)p.height)) == null)
            {
                printf("Unable to allocate memory for artwork\n");
                return 0;
            }

            orientation = (uint)Machine.orientation;

            int tmp = 0;//p.image;
            for (y = 0; y < p.height; y++)
                for (x = 0; x < p.width; x++)
                {
                    plot_pixel(bitmap, (int)x, (int)y, p.image[tmp++]);
                }

            p.image = null;
            return 1;
        }
Esempio n. 3
0
 static void png_delete_unused_colors(png_info p)
 {
     throw new Exception();
 }
Esempio n. 4
0
 static int png_expand_buffer_8bit(png_info p)
 {
     throw new Exception();
 }
Esempio n. 5
0
 static int png_read_file(object fp, png_info p)
 {
     throw new Exception();
 }