Bug 1136
Saving images from UV editing window was confused... initially I thought it only used the same format as input image, but it did use the same as F10 buttons specified, sorta. Fixes include: - BIF_write_ibuf() now uses current Scene renderdata to check for image type (it checked the global R struct instead, which is only set correct after render) - Fileselector now gives correct title in bar (like "SAVE TARGA") - Pulldown menu in UV window now always gives the "Save" option - removed the weird usage of BTST() to check for flags, and made it using the #defines instead for readability
This commit is contained in:
@@ -66,6 +66,7 @@
|
|||||||
#include "BKE_image.h"
|
#include "BKE_image.h"
|
||||||
#include "BKE_main.h"
|
#include "BKE_main.h"
|
||||||
#include "BKE_packedFile.h"
|
#include "BKE_packedFile.h"
|
||||||
|
|
||||||
#include "BLI_blenlib.h"
|
#include "BLI_blenlib.h"
|
||||||
#include "BIF_drawimage.h"
|
#include "BIF_drawimage.h"
|
||||||
#include "BIF_editsima.h"
|
#include "BIF_editsima.h"
|
||||||
@@ -76,8 +77,10 @@
|
|||||||
#include "BIF_toets.h"
|
#include "BIF_toets.h"
|
||||||
#include "BIF_toolbox.h"
|
#include "BIF_toolbox.h"
|
||||||
#include "BIF_writeimage.h"
|
#include "BIF_writeimage.h"
|
||||||
|
|
||||||
#include "BSE_filesel.h"
|
#include "BSE_filesel.h"
|
||||||
#include "BSE_headerbuttons.h"
|
#include "BSE_headerbuttons.h"
|
||||||
|
|
||||||
#include "IMB_imbuf.h"
|
#include "IMB_imbuf.h"
|
||||||
#include "IMB_imbuf_types.h"
|
#include "IMB_imbuf_types.h"
|
||||||
|
|
||||||
@@ -338,7 +341,9 @@ void do_image_buttons(unsigned short event)
|
|||||||
if (ima) {
|
if (ima) {
|
||||||
strcpy(name, ima->name);
|
strcpy(name, ima->name);
|
||||||
if (ima->ibuf) {
|
if (ima->ibuf) {
|
||||||
activate_fileselect(FILE_SPECIAL, "Save in same type", name, save_paint);
|
char str[32]; // sufficient for message
|
||||||
|
save_image_filesel_str(str);
|
||||||
|
activate_fileselect(FILE_SPECIAL, str, name, save_paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -353,8 +358,8 @@ static void do_image_viewmenu(void *arg, int event)
|
|||||||
|
|
||||||
switch(event) {
|
switch(event) {
|
||||||
case 0: /* Update Automatically */
|
case 0: /* Update Automatically */
|
||||||
if(BTST(G.sima->lock, 0)) G.sima->lock = BCLR(G.sima->lock, 0);
|
if(G.sima->lock) G.sima->lock = 0;
|
||||||
else G.sima->lock = BSET(G.sima->lock, 0);
|
else G.sima->lock = 1;
|
||||||
break;
|
break;
|
||||||
case 1: /* View All */
|
case 1: /* View All */
|
||||||
do_image_buttons(B_SIMAGEHOME);
|
do_image_buttons(B_SIMAGEHOME);
|
||||||
@@ -395,7 +400,7 @@ static uiBlock *image_viewmenu(void *arg_unused)
|
|||||||
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Draw Shadow mesh|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
|
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Draw Shadow mesh|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
|
||||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||||
|
|
||||||
if(BTST(G.sima->lock, 0)) {
|
if(G.sima->lock) {
|
||||||
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Update Automatically|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
|
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Update Automatically|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
|
||||||
} else {
|
} else {
|
||||||
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Update Automatically|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
|
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Update Automatically|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
|
||||||
@@ -529,7 +534,7 @@ static uiBlock *image_image_rtmappingmenu(void *arg_unused)
|
|||||||
block= uiNewBlock(&curarea->uiblocks, "image_image_rtmappingmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
|
block= uiNewBlock(&curarea->uiblocks, "image_image_rtmappingmenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
|
||||||
uiBlockSetButmFunc(block, do_image_image_rtmappingmenu, NULL);
|
uiBlockSetButmFunc(block, do_image_image_rtmappingmenu, NULL);
|
||||||
|
|
||||||
if (BTST(G.sima->image->flag, 4)) {
|
if (G.sima->image->flag & IMA_REFLECT) {
|
||||||
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "UV Co-ordinates", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
|
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "UV Co-ordinates", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 0, "");
|
||||||
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Reflection", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
|
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Reflection", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
|
||||||
} else {
|
} else {
|
||||||
@@ -603,15 +608,17 @@ static void do_image_imagemenu(void *arg, int event)
|
|||||||
allqueue(REDRAWHEADERS, 0);
|
allqueue(REDRAWHEADERS, 0);
|
||||||
break;
|
break;
|
||||||
case 4: /* Texture Painting */
|
case 4: /* Texture Painting */
|
||||||
if(BTST(G.sima->flag, 3)) G.sima->flag = BCLR(G.sima->flag, 3);
|
if(G.sima->flag & SI_DRAWTOOL) G.sima->flag &= ~SI_DRAWTOOL;
|
||||||
else G.sima->flag = BSET(G.sima->flag, 3);
|
else G.sima->flag |= SI_DRAWTOOL;
|
||||||
break;
|
break;
|
||||||
case 5: /* Save Painted Image */
|
case 5: /* Save Painted Image */
|
||||||
ima = G.sima->image;
|
ima = G.sima->image;
|
||||||
if (ima) {
|
if (ima) {
|
||||||
strcpy(name, ima->name);
|
strcpy(name, ima->name);
|
||||||
if (ima->ibuf) {
|
if (ima->ibuf) {
|
||||||
activate_fileselect(FILE_SPECIAL, "Save As Same Type", name, save_paint);
|
char str[32]; // sufficient for message
|
||||||
|
save_image_filesel_str(str);
|
||||||
|
activate_fileselect(FILE_SPECIAL, str, name, save_paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -645,11 +652,12 @@ static uiBlock *image_imagemenu(void *arg_unused)
|
|||||||
block= uiNewBlock(&curarea->uiblocks, "image_imagemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
|
block= uiNewBlock(&curarea->uiblocks, "image_imagemenu", UI_EMBOSSP, UI_HELV, curarea->headwin);
|
||||||
uiBlockSetButmFunc(block, do_image_imagemenu, NULL);
|
uiBlockSetButmFunc(block, do_image_imagemenu, NULL);
|
||||||
|
|
||||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Open...|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
|
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Open...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
|
||||||
|
|
||||||
if (G.sima->image) {
|
if (G.sima->image) {
|
||||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Replace...|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
|
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
|
||||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reload|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
|
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Replace...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
|
||||||
|
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reload", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
|
||||||
|
|
||||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||||
|
|
||||||
@@ -661,9 +669,8 @@ static uiBlock *image_imagemenu(void *arg_unused)
|
|||||||
|
|
||||||
uiDefBut(block, SEPR, 0, "", 0, yco-=7, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
uiDefBut(block, SEPR, 0, "", 0, yco-=7, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||||
|
|
||||||
if(BTST(G.sima->flag, 3)) {
|
if(G.sima->flag & SI_DRAWTOOL) {
|
||||||
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Texture Painting", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
|
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Texture Painting", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
|
||||||
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Painted Image...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, "");
|
|
||||||
} else {
|
} else {
|
||||||
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Texture Painting", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
|
uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Texture Painting", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
|
||||||
}
|
}
|
||||||
@@ -799,12 +806,12 @@ static void do_image_uvsmenu(void *arg, int event)
|
|||||||
switch(event)
|
switch(event)
|
||||||
{
|
{
|
||||||
case 1: /* UVs Constrained Rectangular */
|
case 1: /* UVs Constrained Rectangular */
|
||||||
if(BTST(G.sima->flag, 0)) G.sima->flag = BCLR(G.sima->flag, 0);
|
if(G.sima->flag & SI_BE_SQUARE) G.sima->flag &= ~SI_BE_SQUARE;
|
||||||
else G.sima->flag = BSET(G.sima->flag, 0);
|
else G.sima->flag |= SI_BE_SQUARE;
|
||||||
break;
|
break;
|
||||||
case 2: /* UVs Clipped to Image Size */
|
case 2: /* UVs Clipped to Image Size */
|
||||||
if(BTST(G.sima->flag, 2)) G.sima->flag = BCLR(G.sima->flag, 2);
|
if(G.sima->flag & SI_CLIP_UV) G.sima->flag &= ~SI_CLIP_UV;
|
||||||
else G.sima->flag = BSET(G.sima->flag, 2);
|
else G.sima->flag |= SI_CLIP_UV;
|
||||||
break;
|
break;
|
||||||
case 3: /* Limit Stitch UVs */
|
case 3: /* Limit Stitch UVs */
|
||||||
stitch_uv_tface(1);
|
stitch_uv_tface(1);
|
||||||
@@ -819,8 +826,8 @@ static void do_image_uvsmenu(void *arg, int event)
|
|||||||
G.f |= G_PROPORTIONAL;
|
G.f |= G_PROPORTIONAL;
|
||||||
break;
|
break;
|
||||||
case 7: /* UVs Snap to Pixel */
|
case 7: /* UVs Snap to Pixel */
|
||||||
if(BTST(G.sima->flag, 7)) G.sima->flag = BCLR(G.sima->flag, 7);
|
if(G.sima->flag & SI_NOPIXELSNAP) G.sima->flag &= ~SI_NOPIXELSNAP;
|
||||||
else G.sima->flag = BSET(G.sima->flag, 7);
|
else G.sima->flag |= SI_NOPIXELSNAP;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -835,13 +842,13 @@ static uiBlock *image_uvsmenu(void *arg_unused)
|
|||||||
|
|
||||||
// uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Transform Properties...|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
|
// uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Transform Properties...|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
|
||||||
// uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
// uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||||
if(BTST(G.sima->flag, 7)) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Snap to Pixels|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
|
if(G.sima->flag & SI_NOPIXELSNAP) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Snap to Pixels|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
|
||||||
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Snap to Pixels|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
|
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Snap to Pixels|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, "");
|
||||||
|
|
||||||
if(BTST(G.sima->flag, 0)) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Quads Constrained Rectangular|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
|
if(G.sima->flag & SI_BE_SQUARE) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Quads Constrained Rectangular|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
|
||||||
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Quads Constrained Rectangular|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
|
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Quads Constrained Rectangular|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
|
||||||
|
|
||||||
if(BTST(G.sima->flag, 2)) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Layout Clipped to Image Size|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
|
if(G.sima->flag & SI_CLIP_UV) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Layout Clipped to Image Size|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
|
||||||
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Layout Clipped to Image Size|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
|
else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Layout Clipped to Image Size|", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
|
||||||
|
|
||||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||||
|
|||||||
@@ -32,12 +32,17 @@
|
|||||||
|
|
||||||
#include "IMB_imbuf.h"
|
#include "IMB_imbuf.h"
|
||||||
#include "IMB_imbuf_types.h" // ImBuf{}
|
#include "IMB_imbuf_types.h" // ImBuf{}
|
||||||
|
|
||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
#include "DNA_texture_types.h" // EnvMap{}
|
#include "DNA_texture_types.h" // EnvMap{}
|
||||||
#include "DNA_image_types.h" // Image{}
|
#include "DNA_image_types.h" // Image{}
|
||||||
|
|
||||||
|
#include "BKE_global.h" // struct G
|
||||||
#include "BKE_utildefines.h" // ELEM
|
#include "BKE_utildefines.h" // ELEM
|
||||||
|
|
||||||
#include "BIF_writeimage.h"
|
#include "BIF_writeimage.h"
|
||||||
#include "render.h"
|
|
||||||
|
#include "render.h" // RE_make_existing_file
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
@@ -49,27 +54,27 @@ int BIF_write_ibuf(ImBuf *ibuf, char *name)
|
|||||||
|
|
||||||
/* to be used for e.g. envmap, not rendered images */
|
/* to be used for e.g. envmap, not rendered images */
|
||||||
|
|
||||||
if(R.r.imtype== R_IRIS) ibuf->ftype= IMAGIC;
|
if(G.scene->r.imtype== R_IRIS) ibuf->ftype= IMAGIC;
|
||||||
else if ((R.r.imtype==R_PNG)) {
|
else if ((G.scene->r.imtype==R_PNG)) {
|
||||||
ibuf->ftype= PNG;
|
ibuf->ftype= PNG;
|
||||||
}
|
}
|
||||||
else if ((R.r.imtype==R_BMP)) {
|
else if ((G.scene->r.imtype==R_BMP)) {
|
||||||
ibuf->ftype= BMP;
|
ibuf->ftype= BMP;
|
||||||
}
|
}
|
||||||
else if ((R.r.imtype==R_TARGA) || (R.r.imtype==R_PNG)) {
|
else if ((G.scene->r.imtype==R_TARGA) || (G.scene->r.imtype==R_PNG)) {
|
||||||
// fall back to Targa if PNG writing is not supported
|
// fall back to Targa if PNG writing is not supported
|
||||||
ibuf->ftype= TGA;
|
ibuf->ftype= TGA;
|
||||||
}
|
}
|
||||||
else if(R.r.imtype==R_RAWTGA) {
|
else if(G.scene->r.imtype==R_RAWTGA) {
|
||||||
ibuf->ftype= RAWTGA;
|
ibuf->ftype= RAWTGA;
|
||||||
}
|
}
|
||||||
else if(R.r.imtype==R_HAMX) {
|
else if(G.scene->r.imtype==R_HAMX) {
|
||||||
ibuf->ftype= AN_hamx;
|
ibuf->ftype= AN_hamx;
|
||||||
}
|
}
|
||||||
else if ELEM(R.r.imtype, R_JPEG90, R_MOVIE) {
|
else if ELEM(G.scene->r.imtype, R_JPEG90, R_MOVIE) {
|
||||||
if(R.r.quality < 10) R.r.quality= 90;
|
if(G.scene->r.quality < 10) G.scene->r.quality= 90;
|
||||||
|
|
||||||
ibuf->ftype= JPG|R.r.quality;
|
ibuf->ftype= JPG|G.scene->r.quality;
|
||||||
}
|
}
|
||||||
else ibuf->ftype= TGA;
|
else ibuf->ftype= TGA;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user