Exemplo n.º 1
0
// [SL] Stretches a patch to fill the full-screen while maintaining a 4:3
// aspect ratio. Pillarboxing is used in widescreen resolutions.
void DCanvas::DrawPatchFullScreen(const patch_t* patch) const
{
	Clear(0, 0, width, height, 0);

	if (isProtectedRes())
	{
		DrawPatch(patch, 0, 0);
	}   
	else if (width * 3 > height * 4)
	{   
		// widescreen resolution - draw pic in 4:3 ratio in center of screen
		int picwidth = 4 * height / 3;
		int picheight = height;
		DrawPatchStretched(patch, (width - picwidth) / 2, 0, picwidth, picheight);
	}   
	else
	{
		// 4:3 resolution - draw pic to the entire screen
		DrawPatchStretched(patch, 0, 0, width, height);
	}
}
Exemplo n.º 2
0
// Draw a patch scaled to a specific width and height, preserving aspect ratio.
void DrawPatchScaled(const int x, const int y,
                     unsigned short w, unsigned short h,
                     const float scale,
                     const x_align_t x_align, const y_align_t y_align,
                     const x_align_t x_origin, const y_align_t y_origin,
                     const patch_t* patch, const bool force_opaque,
                     const bool use_patch_offsets) {
	// Calculate aspect ratios of patch and destination.
	float patch_aspect = patch->width() / (float)patch->height();
	float dest_aspect = w / (float)h;

	if (patch_aspect < dest_aspect) {
		// Destination is wider than patch.  Keep height, calculate width.
		w = (patch->width() * h) / patch->height();
	} else if (patch_aspect > dest_aspect) {
		// Destination is taller than patch.  Keep width, calculate height.
		h = (patch->height() * w) / patch->width();
	}

	// Call the 'stretched' drawer with our new dest. width and height.
	DrawPatchStretched(x, y, w, h, scale, x_align, y_align, x_origin, y_origin,
	                   patch, force_opaque, use_patch_offsets);
}