[Bf-committers] Crop/Zoom feature solution

Johnny Matthews johnny.matthews at gmail.com
Fri Feb 11 17:46:34 CET 2005


Chris, I tried your patch and it looks good to me! Worked like a charm. 
I think that makes a lot of sense. I tried some small border renders and 
some super huge and saw no problems. Very handy!

Johnny (guitarGeek)

Chris Burt wrote:

> Not sure if anyone else has a problem with this functionality:
>
>     Border and crop are turned on, image dimensions set
>     very high. Render window is bigger than screen, so
>     it scales down, but border selected area is not.
>     Thus your selected content is scaled down to fit
>     inside the enormous gray void created by crop.
>
> My solution was to scale the render window based on the relative 
> coordinates stored within the RenderData struct. This data is given in 
> floats stored in r.border.xmax, r.border.xmin, r.border.ymax, and 
> r.border.ymin. By finding the difference of these two pairs one ends 
> up with a factor by which the render window can be multiplied to yield 
> the proper dimensions for the render window to fit the cropped image. 
> I also had to correct the zoom which occurs automatically if the 
> window is scaled in the case that R_BORDER and R_MOVIECROP are active. 
> Thus no more HUGE render window just to contain a tiny piece of your 
> render.
>
> I think this functionality is an improvement and should let people 
> fuss with the render window less just to see how a portion of their 
> render will look. I'm fairly confident it doesn't break anything but 
> testers should... well... test. I hope this can be included in the 
> main tree. Thanks!
>
> --Chris Burt
>
>------------------------------------------------------------------------
>
>Index: source/blender/src/renderwin.c
>===================================================================
>RCS file: /cvsroot/bf-blender/blender/source/blender/src/renderwin.c,v
>retrieving revision 1.43
>diff -u -p -r1.43 renderwin.c
>--- source/blender/src/renderwin.c	3 Jan 2005 13:40:11 -0000	1.43
>+++ source/blender/src/renderwin.c	11 Feb 2005 14:35:22 -0000
>@@ -237,9 +237,19 @@ static void renderwin_reset_view(RenderW
> 	window_get_size(rw->win, &w, &h);
> 	h-= RW_HEADERY;
> 	
>-		/* at this point the r.rectx/y values are not correct yet */
>-	rectx= (G.scene->r.size*G.scene->r.xsch)/100;
>-	recty= (G.scene->r.size*G.scene->r.ysch)/100;
>+	/* at this point the r.rectx/y values are not correct yet */
>+	
>+		/* Check and see if border and crop are turned on. If they are, calculate
>+		a zoom factor that ignores clipped areas, and thus zooms border selected
>+		area to fill matching render window size calculated in calc_renderwin_rectangle */
>+	if ((G.scene->r.mode & R_BORDER) && (G.scene->r.mode & R_MOVIECROP)) { 
>+		rectx= ( (int)((G.scene->r.border.xmax-G.scene->r.border.xmin)*100)*G.scene->r.xsch)/100;
>+		recty= ( (int)((G.scene->r.border.ymax-G.scene->r.border.ymin)*100)*G.scene->r.ysch)/100;
>+	}
>+	else {
>+		rectx= (G.scene->r.size*G.scene->r.xsch)/100;
>+		recty= (G.scene->r.size*G.scene->r.ysch)/100;
>+	}
> 
> 	if(rectx>w || recty>h) {
> 		if(rectx-w > recty-h) rw->zoom= ((float)w)/((float)rectx);
>@@ -587,8 +597,22 @@ void calc_renderwin_rectangle(int posmas
> 		 */
> 	winlay_get_screensize(&scr_w, &scr_h);
> 	
>-	rendersize_r[0]= (G.scene->r.size*G.scene->r.xsch)/100;
>-	rendersize_r[1]= (G.scene->r.size*G.scene->r.ysch)/100;
>+		/* If Crop and Border are active, multiply window dimensions 
>+		by difference of relative dimensions stored in r.border to get
>+		factor to scale render window. Else calculate window
>+		dimensions normally. Still zooms if selected area is larger
>+		than screen dimensions so should be safe. - Chris Burt
>+		 */
>+	
>+	if((G.scene->r.mode & R_BORDER) && (G.scene->r.mode & R_MOVIECROP)) {
>+		rendersize_r[0]= (G.scene->r.size*G.scene->r.xsch*(G.scene->r.border.xmax-G.scene->r.border.xmin))/100;
>+		rendersize_r[1]= (G.scene->r.size*G.scene->r.ysch*(G.scene->r.border.ymax-G.scene->r.border.ymin))/100;
>+	}
>+	else {
>+		rendersize_r[0]= (G.scene->r.size*G.scene->r.xsch)/100;
>+		rendersize_r[1]= (G.scene->r.size*G.scene->r.ysch)/100;
>+	}
>+	
> 	if(G.scene->r.mode & R_PANORAMA) {
> 		rendersize_r[0]*= G.scene->r.xparts;
> 		rendersize_r[1]*= G.scene->r.yparts;
>  
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Bf-committers mailing list
>Bf-committers at projects.blender.org
>http://projects.blender.org/mailman/listinfo/bf-committers
>  
>



More information about the Bf-committers mailing list