changeset 2305:82c17b134946

Fixed half-image bug and added computing of correct aspect during zooming
author nick
date Sat, 20 Oct 2001 12:53:20 +0000
parents 0769b2fb3ce2
children 42cf51474f45
files libvo/vo_vesa.c
diffstat 1 files changed, 31 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_vesa.c	Sat Oct 20 11:58:45 2001 +0000
+++ b/libvo/vo_vesa.c	Sat Oct 20 12:53:20 2001 +0000
@@ -212,16 +212,17 @@
 */
 static void __vbeCopyData(uint8_t *image)
 {
-   unsigned long i,image_offset,offset;
+   unsigned long i,j,image_offset,offset,limit;
    unsigned pixel_size,image_line_size,screen_line_size,x_shift;
    pixel_size = (video_mode_info.BitsPerPixel+7)/8;
    screen_line_size = video_mode_info.XResolution*pixel_size;
    image_line_size = image_width*pixel_size;
    x_shift = x_offset*pixel_size;
-   for(i=y_offset;i<image_height;i++)
+   limit = image_height+y_offset;
+   for(j=0,i=y_offset;i<limit;i++,j++)
    {
      offset = i*screen_line_size+x_shift;
-     image_offset = i*image_line_size;
+     image_offset = j*image_line_size;
      __vbeCopyBlock(offset,&image[image_offset],image_line_size);
    }
 }
@@ -292,6 +293,23 @@
 	return retval;
 }
 
+static void vesa_aspect(uint32_t width,uint32_t height,  
+		    	uint32_t xres,uint32_t yres,
+			uint32_t *image_width,uint32_t *image_height)
+{
+  float factor;
+  factor = (float)width / height;
+  *image_width = xres;
+  *image_height = xres / factor;
+  if(verbose) printf("vo_vesa: aspect factor = %f(%ux%u) *image=%ux%u screen=%ux%u\n",factor,width,height,*image_width,*image_height,xres,yres);
+  if((*image_height) > yres)
+  {
+    *image_height = yres;
+    *image_width = yres * factor;
+    if(verbose) printf("vo_vesa: Y > X tehrefore *image=%ux%u\n",*image_width,*image_height);
+  }
+}
+
 static char *model2str(unsigned char type)
 {
   char *retval;
@@ -459,8 +477,11 @@
 		  if( format==IMGFMT_YV12 )
 		  {
 		      /* software scale */
-		      image_width = video_mode_info.XResolution;
-		      image_height = video_mode_info.YResolution;
+		      vesa_aspect(width,height,  
+		    		  video_mode_info.XResolution,video_mode_info.YResolution,
+				  &image_width,&image_height);
+/*		      image_width = video_mode_info.XResolution;
+		      image_height = video_mode_info.YResolution; */
 		      scale_xinc=(width << 16) / image_width - 2;  /* needed for proper rounding */
 	    	      scale_yinc=(height << 16) / image_height + 2;
 		      SwScale_Init();
@@ -490,6 +511,11 @@
 		win.high= video_mode_info.WinSize*1024;
 		x_offset = (video_mode_info.XResolution - image_width) / 2;
 		y_offset = (video_mode_info.YResolution - image_height) / 2;
+		if(verbose)
+		  printf("vo_vesa: image: %ux%u screen = %ux%u x_offset = %u y_offset = %u\n"
+			,image_width,image_height
+			,video_mode_info.XResolution,video_mode_info.YResolution
+			,x_offset,y_offset);
 		if((err=vbeSaveState(&init_state)) != VBE_OK)
 		{
 			PRINT_VBE_ERR("vbeSaveState",err);