[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: CVS update: x_image.nw



  User: ahvezda 
  Date: 05/09/05 16:19:06

  Modified:    .        x_image.nw
  Log:
  Applied patch to fix PNG proportions (patch by Michael Hanselmann)
  
  
  
  
  Revision  Changes    Path
  1.15      +29 -8     eda/geda/devel/gschem/noweb/x_image.nw
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: x_image.nw
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gschem/noweb/x_image.nw,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -b -r1.14 -r1.15
  --- x_image.nw	12 Feb 2005 01:20:39 -0000	1.14
  +++ x_image.nw	5 Sep 2005 20:19:06 -0000	1.15
  @@ -315,6 +315,8 @@
   {
     int width, height;
     int save_height, save_width;
  +  int save_page_left, save_page_right, save_page_top, save_page_bottom;
  +  int page_width, page_height, page_center_left, page_center_top;
   
     width = w_current->image_width;
     height = w_current->image_height;
  @@ -325,12 +327,31 @@
     w_current->width = width;
     w_current->height = height;
   
  +  save_page_left = w_current->page_current->left;
  +  save_page_right = w_current->page_current->right;
  +  save_page_top = w_current->page_current->top;
  +  save_page_bottom = w_current->page_current->bottom;
  +  
  +  page_width = save_page_right - save_page_left;
  +  page_height = save_page_bottom - save_page_top;
  +
  +  page_center_left = save_page_left + (page_width / 2);
  +  page_center_top = save_page_top + (page_height / 2);
  +
  +  /* Preserve proportions */
  +  float prop = (float)width / height;
  +  if(page_width > page_height) {
  +    page_height = (page_width / prop);
  +  }else{
  +    page_width = (page_height * prop);
  +  }
  +
     /* need to do this every time you change width / height */
     set_window(w_current, w_current->page_current,
  -             w_current->page_current->left,
  -             w_current->page_current->right,
  -             w_current->page_current->top,
  -             w_current->page_current->bottom);
  +             page_center_left - (page_width / 2),
  +             page_center_left + (page_width / 2),
  +             page_center_top - (page_height / 2),
  +             page_center_top + (page_height / 2));
   
     /* de select everything first */
     o_selection_remove_most(w_current,
  @@ -348,10 +369,10 @@
   
     /* need to do this every time you change width / height */
     set_window(w_current, w_current->page_current,
  -             w_current->page_current->left,
  -             w_current->page_current->right,
  -             w_current->page_current->top,
  -             w_current->page_current->bottom);
  +             save_page_left,
  +             save_page_right,
  +             save_page_top,
  +             save_page_bottom);
   
     /* try to use recalc here... */
     o_redraw_all(w_current);