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