diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-12-01 02:38:31 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-12-01 02:38:31 +0300 |
commit | 89abb9f2d2470cf808fd1f42c67d82355d1ade8e (patch) | |
tree | 267d5be53e0598558e1aef69dd94a84c10350d71 /source/blender/blenkernel | |
parent | d9c23d8d5d1cddfe48fbeecee0a23dacd2d60d59 (diff) |
bugfix [#22638] Alpha channel not saved when using texture paint
check for alpha channel while saving images that have been painted onto.
It would be nicer to do this while in paint mode except this isn't so simple with project paint using multiple images at once.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_image.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 7a801c0ef0a..46c7cd89ecf 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -46,6 +46,7 @@ void free_image(struct Image *me); void BKE_stamp_info(struct Scene *scene, struct ImBuf *ibuf); void BKE_stamp_buf(struct Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels); +int BKE_alphatest_ibuf(struct ImBuf *ibuf); int BKE_write_ibuf(struct Scene *scene, struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality); void BKE_makepicstring(char *string, const char *base, int frame, int imtype, const short use_ext, const short use_frames); int BKE_add_image_extension(char *string, int imtype); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index b624feeaf9d..31eae70f159 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1188,6 +1188,29 @@ void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) if (stamp_data.rendertime[0]) IMB_metadata_change_field (ibuf, "RenderTime", stamp_data.rendertime); } +int BKE_alphatest_ibuf(ImBuf *ibuf) +{ + int tot; + if(ibuf->rect_float) { + float *buf= ibuf->rect_float; + for(tot= ibuf->x * ibuf->y; tot--; buf+=4) { + if(buf[3] < 1.0f) { + return TRUE; + } + } + } + else if (ibuf->rect) { + unsigned char *buf= (unsigned char *)ibuf->rect; + for(tot= ibuf->x * ibuf->y; tot--; buf+=4) { + if(buf[3] != 255) { + return TRUE; + } + } + } + + return FALSE; +} + int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality) { int ok; |