Bugfix #5497
authorTon Roosendaal <ton@blender.org>
Sat, 23 Dec 2006 11:22:20 +0000 (11:22 +0000)
committerTon Roosendaal <ton@blender.org>
Sat, 23 Dec 2006 11:22:20 +0000 (11:22 +0000)
Imagewindow: new Jkey (swap render rects) feature didn't correctly support
the Curves panel.

source/blender/include/BIF_drawimage.h
source/blender/src/drawimage.c
source/blender/src/header_image.c

index 5c289cfc2a4c7fb6170f86a85347324f138734d2..b296107f084741162a07a5b97439f7a25c65ed64 100644 (file)
@@ -61,6 +61,7 @@ void imagewindow_render_callbacks(struct Render *re);
 void imagewindow_toggle_render(void);
 void imagewindow_swap_render_rects(void);
 void imagewin_store_spare(void);
+struct ImBuf *imagewindow_get_ibuf(struct SpaceImage *sima);
 
 void image_editvertex_buts(struct uiBlock *block);
 
index da41f40602be54adcf8adb4d79e1b88e0e646778..4f54ab1cb8b62a01ed45fbbbed9824477f4045f0 100644 (file)
@@ -271,6 +271,21 @@ void what_image(SpaceImage *sima)
        }
 }
 
+/* after a what_image(), this call will give ibufs, includes the spare image */
+ImBuf *imagewindow_get_ibuf(SpaceImage *sima)
+{
+       
+       if(G.sima->image) {
+               /* check for spare */
+               if(sima->image->type==IMA_TYPE_R_RESULT && sima->showspare)
+                       return sima->spare;
+               else
+                       return BKE_image_get_ibuf(sima->image, &sima->iuser);
+       }
+       return NULL;
+}
+
+
 /* called to assign images to UV faces */
 void image_changed(SpaceImage *sima, int dotile)
 {
@@ -737,7 +752,7 @@ void image_editvertex_buts(uiBlock *block)
        me= get_mesh(OBACT);
        
        if (G.sima->image) {
-               ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
+               ImBuf *ibuf= imagewindow_get_ibuf(G.sima);
                if(ibuf) {
                        imx= ibuf->x;
                        imy= ibuf->y;
@@ -1042,10 +1057,13 @@ static void image_panel_curves_reset(void *cumap_v, void *ibuf_v)
 
 static void image_panel_curves(short cntrl)    // IMAGE_HANDLER_CURVES
 {
-       ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
+       ImBuf *ibuf;
        uiBlock *block;
        uiBut *bt;
        
+       /* and we check for spare */
+       ibuf= imagewindow_get_ibuf(G.sima);
+       
        block= uiNewBlock(&curarea->uiblocks, "image_panel_curves", UI_EMBOSS, UI_HELV, curarea->win);
        uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl);
        uiSetPanelHandler(IMAGE_HANDLER_CURVES);  // for close and esc
@@ -1553,10 +1571,7 @@ void drawimagespace(ScrArea *sa, void *spacedata)
                        }
                }
                /* and we check for spare */
-               if(sima->image->type==IMA_TYPE_R_RESULT && sima->showspare)
-                       ibuf= sima->spare;
-               else
-                       ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
+               ibuf= imagewindow_get_ibuf(sima);
        }
        
        if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) {
@@ -1784,7 +1799,7 @@ static void image_zoom_set_factor(float zoomfac)
        width= 256;
        height= 256;
        if (sima->image) {
-               ImBuf *ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
+               ImBuf *ibuf= imagewindow_get_ibuf(sima);
 
                if (ibuf) {
                        float xim, yim;
@@ -1896,12 +1911,13 @@ void image_viewzoom(unsigned short event, int invert)
  */
 void image_home(void)
 {
-       ImBuf *ibuf= BKE_image_get_ibuf(G.sima->image, &G.sima->iuser);
+       ImBuf *ibuf;
        int width, height, imgwidth, imgheight;
        float zoomX, zoomY;
 
        if (curarea->spacetype != SPACE_IMAGE) return;
-
+       ibuf= imagewindow_get_ibuf(G.sima);
+       
        if (ibuf == NULL) {
                imgwidth = 256;
                imgheight = 256;
index 340170c03e210845ff9aab4a067520f8f25d0747..2fad10f0e39cf597f74008e72644856c7ad61127 100644 (file)
@@ -259,13 +259,13 @@ void do_image_buttons(unsigned short event)
                break;
                
        case B_SIMACURVES:
-               curvemapping_do_ibuf(G.sima->cumap, BKE_image_get_ibuf(G.sima->image, &G.sima->iuser));
+               curvemapping_do_ibuf(G.sima->cumap, imagewindow_get_ibuf(G.sima));
                allqueue(REDRAWIMAGE, 0);
                break;
                
        case B_SIMARANGE:
                curvemapping_set_black_white(G.sima->cumap, NULL, NULL);
-               curvemapping_do_ibuf(G.sima->cumap, BKE_image_get_ibuf(G.sima->image, &G.sima->iuser));
+               curvemapping_do_ibuf(G.sima->cumap, imagewindow_get_ibuf(G.sima));
                allqueue(REDRAWIMAGE, 0);
                break;