示例#1
0
文件: rendutil.cs 项目: kwanboy/mcs
        /*-------------------------------------------------
        *   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();
        }
示例#2
0
        /* ----- render utilities ----- */

        /*-------------------------------------------------
        *   render_resample_argb_bitmap_hq - perform a high
        *   quality resampling of a texture
        *  -------------------------------------------------*/
        public static void render_resample_argb_bitmap_hq(bitmap_argb32 dest, bitmap_argb32 source, render_color color, bool force = false)
        {
            if (dest.width() == 0 || dest.height() == 0)
            {
                return;
            }

            /* adjust the source base */
            PointerU32 sbase = source.pix(0);  //const u32 *sbase = &source.pix(0);

            /* determine the steppings */
            u32 swidth  = (u32)source.width();
            u32 sheight = (u32)source.height();
            u32 dwidth  = (u32)dest.width();
            u32 dheight = (u32)dest.height();
            u32 dx      = (swidth << 12) / dwidth;
            u32 dy      = (sheight << 12) / dheight;

            /* if the source is higher res than the target, use full averaging */
            if (dx > 0x1000 || dy > 0x1000 || force)
            {
                resample_argb_bitmap_average(dest.pix(0), (u32)dest.rowpixels(), dwidth, dheight, sbase, (u32)source.rowpixels(), swidth, sheight, color, dx, dy);
            }
            else
            {
                resample_argb_bitmap_bilinear(dest.pix(0), (u32)dest.rowpixels(), dwidth, dheight, sbase, (u32)source.rowpixels(), swidth, sheight, color, dx, dy);
            }
        }
示例#3
0
文件: rendutil.cs 项目: kwanboy/mcs
        //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();
        }
示例#4
0
文件: rendutil.cs 项目: kwanboy/mcs
        /* ----- render utilities ----- */

        /*-------------------------------------------------
        *   render_resample_argb_bitmap_hq - perform a high
        *   quality resampling of a texture
        *  -------------------------------------------------*/
        public static void render_resample_argb_bitmap_hq(bitmap_argb32 dest, bitmap_argb32 source, render_color color, bool force = false)
        {
            if (dest.width() == 0 || dest.height() == 0)
            {
                return;
            }

            /* adjust the source base */
            //const UINT32 *sbase = &source.pix32(0);
            RawBuffer sbaseBuf;
            u32       sbaseOffset = source.pix32(out sbaseBuf, 0);

            /* determine the steppings */
            u32 swidth  = (u32)source.width();
            u32 sheight = (u32)source.height();
            u32 dwidth  = (u32)dest.width();
            u32 dheight = (u32)dest.height();
            u32 dx      = (swidth << 12) / dwidth;
            u32 dy      = (sheight << 12) / dheight;

            //throw new emu_unimplemented();
            /* if the source is higher res than the target, use full averaging */
            if (dx > 0x1000 || dy > 0x1000 || force)
            {
                RawBuffer destBuf;
                u32       destOffset = dest.pix32(out destBuf, 0);
                resample_argb_bitmap_average(new RawBufferPointer(destBuf, (int)destOffset), (UInt32)dest.rowpixels(), dwidth, dheight, new RawBufferPointer(sbaseBuf, (int)sbaseOffset), (UInt32)source.rowpixels(), swidth, sheight, color, dx, dy);
            }
            else
            {
                RawBuffer destBuf;
                u32       destOffset = dest.pix32(out destBuf, 0);
                resample_argb_bitmap_bilinear(new RawBufferPointer(destBuf, (int)destOffset), (UInt32)dest.rowpixels(), dwidth, dheight, new RawBufferPointer(sbaseBuf, (int)sbaseOffset), (UInt32)source.rowpixels(), swidth, sheight, color, dx, dy);
            }
        }
示例#5
0
 public glyph()
 {
     width    = -1;
     xoffs    = -1;
     yoffs    = -1;
     bmwidth  = 0;
     bmheight = 0;
     rawdata  = null;
     texture  = null;
     bitmap   = new bitmap_argb32();
     color    = new rgb_t();
 }
示例#6
0
        //-------------------------------------------------
        //  get_scaled_bitmap_and_bounds - return a
        //  scaled bitmap and bounding rect for a char
        //-------------------------------------------------
        public void get_scaled_bitmap_and_bounds(bitmap_argb32 dest, float height, float aspect, char32_t chnum, out rectangle bounds)
        {
            bounds = default;

            glyph gl = get_char(chnum);

            // on entry, assume x0,y0 are the top,left coordinate of the cell and add
            // the character bounding box to that position
            float scale = m_scale * height;

            bounds.min_x = (int)((float)(gl.xoffs) * scale * aspect);
            bounds.min_y = 0;

            // compute x1,y1 from there based on the bitmap size
            bounds.set_width((int)((float)(gl.bmwidth) * scale * aspect));
            bounds.set_height((int)((float)(m_height) * scale));

            // if the bitmap isn't big enough, bail
            if (dest.width() < bounds.width() || dest.height() < bounds.height())
            {
                return;
            }

            // if no texture, fill the target
            if (gl.texture == null)
            {
                dest.fill(0);
                return;
            }

            throw new emu_unimplemented();
#if false
            // scale the font
            bitmap_argb32 tempbitmap = new bitmap_argb32(&dest.pix(0), bounds.width(), bounds.height(), dest.rowpixels());
            render_texture.hq_scale(tempbitmap, gl.bitmap, gl.bitmap.cliprect(), null);
#endif
        }
示例#7
0
 //bitmap_argb32(uint32_t *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { }
 public bitmap_argb32(bitmap_argb32 source, rectangle subrect) : base(k_bitmap_format, source, subrect)
 {
 }
示例#8
0
        // 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);
        }
示例#9
0
        /*-------------------------------------------------
        *   render_load_png - load a PNG file into a
        *   bitmap
        *  -------------------------------------------------*/
        public static bool render_load_png(out bitmap_argb32 bitmap, util.random_read file, bool load_as_alpha_to_existing = false)
        {
            throw new emu_unimplemented();
#if false
#endif
        }
示例#10
0
        /*-------------------------------------------------
        *   render_load_jpeg - load a JPEG file into a
        *   bitmap
        *  -------------------------------------------------*/
        public static void render_load_jpeg(out bitmap_argb32 bitmap, util.random_read file)
        {
            throw new emu_unimplemented();
#if false
#endif
        }
示例#11
0
文件: crsshair.cs 项目: kwanboy/mcs
        // 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()
        {
            int   x;
            int   y;
            rgb_t color = m_player < crosshair_colors.Length ? 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);
            }

            emu_file crossfile = new emu_file(m_machine.options().crosshair_path(), OPEN_FLAG_READ);

            if (!m_name.empty())
            {
                // look for user specified file
                string filename = m_name + ".png";
                render_load_png(out m_bitmap, crossfile, null, filename.c_str());
            }
            else
            {
                // look for default cross?.png in crsshair/game dir
                string filename = string.Format("cross{0}.png", m_player + 1);
                render_load_png(out m_bitmap, crossfile, m_machine.system().name, filename.c_str());

                // look for default cross?.png in crsshair dir
                if (!m_bitmap.valid())
                {
                    render_load_png(out m_bitmap, crossfile, null, filename.c_str());
                }
            }

            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 (y = 0; y < CROSSHAIR_RAW_SIZE / 2; y++)
                {
                    /* assume it is mirrored vertically */
                    //u32 *dest0 = &m_bitmap->pix32(y);
                    RawBuffer dest0Buf;
                    UInt32    dest0Offset = m_bitmap.pix32(out dest0Buf, y);
                    //u32 *dest1 = &m_bitmap->pix32(CROSSHAIR_RAW_SIZE - 1 - y);
                    RawBuffer dest1Buf;
                    UInt32    dest1Offset = m_bitmap.pix32(out dest1Buf, CROSSHAIR_RAW_SIZE - 1 - y);

                    /* extract to two rows simultaneously */
                    for (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;
                            dest0Buf.set_uint32((int)dest0Offset + x, new rgb_t(0xff, 0x00, 0x00, 0x00) | color);
                            dest1Buf.set_uint32((int)dest1Offset + 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);
        }