/*------------------------------------------------- * render_load_png - load a PNG file into a * bitmap * -------------------------------------------------*/ public static bool render_load_png(out bitmap_argb32 bitmap, emu_file file, string dirname, string filename, bool load_as_alpha_to_existing = false) { bitmap = new bitmap_argb32(); // deallocate if we're not overlaying alpha if (!load_as_alpha_to_existing) { bitmap.reset(); } // open the file string fname; if (dirname != null) { fname = dirname + global_object.PATH_SEPARATOR + filename; } else { fname = filename; } osd_file.error filerr = file.open(fname); if (filerr != osd_file.error.NONE) { return(false); } throw new emu_unimplemented(); }
//void render_line_to_quad(const render_bounds *bounds, float width, float length_extension, render_bounds *bounds0, render_bounds *bounds1); /*------------------------------------------------- * render_load_jpeg - load a JPG file into a * bitmap * -------------------------------------------------*/ public static void render_load_jpeg(out bitmap_argb32 bitmap, emu_file file, string dirname, string filename) { bitmap = new bitmap_argb32(); // deallocate previous bitmap bitmap.reset(); // define file's full name string fname; if (dirname == null) { fname = filename; } else { fname = dirname + global_object.PATH_SEPARATOR + filename; } if (file.open(fname) != osd_file.error.NONE) { return; } throw new emu_unimplemented(); }
// updates //void animate(u16 auto_time); //void draw(render_container &container, u8 fade); // private helpers //------------------------------------------------- // create_bitmap - create the rendering // structures for the given player //------------------------------------------------- void create_bitmap() { rgb_t color = m_player < (int)std.size(crosshair_colors) ? crosshair_colors[m_player] : rgb_t.white(); // if we have a bitmap and texture for this player, kill it if (m_bitmap == null) { m_bitmap = new bitmap_argb32(); m_texture = m_machine.render().texture_alloc(render_texture.hq_scale); } else { m_bitmap.reset(); } emu_file crossfile = new emu_file(m_machine.options().crosshair_path(), OPEN_FLAG_READ); if (!m_name.empty()) { // look for user specified file if (!crossfile.open(m_name + ".png")) { render_load_png(out m_bitmap, crossfile.core_file_get()); crossfile.close(); } } else { // look for default cross?.png in crsshair/game dir string filename = util.string_format("cross{0}.png", m_player + 1); if (!crossfile.open(m_machine.system().name + (PATH_SEPARATOR + filename))) { render_load_png(out m_bitmap, crossfile.core_file_get()); crossfile.close(); } // look for default cross?.png in crsshair dir if (!m_bitmap.valid() && !crossfile.open(filename)) { render_load_png(out m_bitmap, crossfile.core_file_get()); crossfile.close(); } } /* if that didn't work, use the built-in one */ if (!m_bitmap.valid()) { /* allocate a blank bitmap to start with */ m_bitmap.allocate(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE); m_bitmap.fill(new rgb_t(0x00, 0xff, 0xff, 0xff)); /* extract the raw source data to it */ for (int y = 0; y < CROSSHAIR_RAW_SIZE / 2; y++) { /* assume it is mirrored vertically */ PointerU32 dest0 = m_bitmap.pix(y); //u32 *dest0 = &m_bitmap->pix(y); PointerU32 dest1 = m_bitmap.pix(CROSSHAIR_RAW_SIZE - 1 - y); //u32 *dest1 = &m_bitmap->pix(CROSSHAIR_RAW_SIZE - 1 - y); /* extract to two rows simultaneously */ for (int x = 0; x < CROSSHAIR_RAW_SIZE; x++) { if (((crosshair_raw_top[y * CROSSHAIR_RAW_ROWBYTES + x / 8] << (x % 8)) & 0x80) != 0) { dest0[x] = dest1[x] = new rgb_t(0xff, 0x00, 0x00, 0x00) | color; } } } } /* reference the new bitmap */ m_texture.set_bitmap(m_bitmap, m_bitmap.cliprect(), texture_format.TEXFORMAT_ARGB32); }