Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/dds/dds_api.cpp
| Show All 38 Lines | |||||
| #include "imbuf.h" | #include "imbuf.h" | ||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| #include "IMB_imbuf.h" | #include "IMB_imbuf.h" | ||||
| #include "IMB_allocimbuf.h" | #include "IMB_allocimbuf.h" | ||||
| #include "IMB_colormanagement.h" | #include "IMB_colormanagement.h" | ||||
| #include "IMB_colormanagement_intern.h" | #include "IMB_colormanagement_intern.h" | ||||
| int imb_save_dds(struct ImBuf *ibuf, const char *name, int /*flags*/) | int imb_save_dds(struct ImBuf *ibuf, const char *name, eImBufFlags /*flags*/) | ||||
| { | { | ||||
| return (0); /* todo: finish this function */ | return (0); /* todo: finish this function */ | ||||
| /* check image buffer */ | /* check image buffer */ | ||||
| if (ibuf == 0) { | if (ibuf == 0) { | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| if (ibuf->rect == 0) { | if (ibuf->rect == 0) { | ||||
| Show All 29 Lines | int imb_is_a_dds(const unsigned char *mem) // note: use at most first 32 bytes | ||||
| if ((mem[4] != 124) || mem[5] || mem[6] || mem[7]) { | if ((mem[4] != 124) || mem[5] || mem[6] || mem[7]) { | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| return (1); | return (1); | ||||
| } | } | ||||
| struct ImBuf *imb_load_dds(const unsigned char *mem, | struct ImBuf *imb_load_dds(const unsigned char *mem, | ||||
| size_t size, | size_t size, | ||||
| int flags, | eImBufFlags flags, | ||||
| char colorspace[IM_MAX_SPACE]) | char colorspace[IM_MAX_SPACE]) | ||||
| { | { | ||||
| struct ImBuf *ibuf = NULL; | struct ImBuf *ibuf = NULL; | ||||
| DirectDrawSurface dds((unsigned char *)mem, size); /* reads header */ | DirectDrawSurface dds((unsigned char *)mem, size); /* reads header */ | ||||
| unsigned char bits_per_pixel; | unsigned char bits_per_pixel; | ||||
| unsigned int *rect; | unsigned int *rect; | ||||
| Image img; | Image img; | ||||
| unsigned int numpixels = 0; | unsigned int numpixels = 0; | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if (img.format() == Image::Format_ARGB) { | ||||
| for (unsigned int i = 0; i < numpixels; i++) { | for (unsigned int i = 0; i < numpixels; i++) { | ||||
| pixel = pixels[i]; | pixel = pixels[i]; | ||||
| if (pixel.a != 255) { | if (pixel.a != 255) { | ||||
| bits_per_pixel = 32; | bits_per_pixel = 32; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ibuf = IMB_allocImBuf(dds.width(), dds.height(), bits_per_pixel, 0); | ibuf = IMB_allocImBuf(dds.width(), dds.height(), bits_per_pixel, static_cast<eImBufFlags>(0)); | ||||
| if (ibuf == 0) { | if (ibuf == 0) { | ||||
| return (0); /* memory allocation failed */ | return (0); /* memory allocation failed */ | ||||
| } | } | ||||
| ibuf->ftype = IMB_FTYPE_DDS; | ibuf->ftype = IMB_FTYPE_DDS; | ||||
| ibuf->dds_data.fourcc = dds.fourCC(); | ibuf->dds_data.fourcc = dds.fourCC(); | ||||
| ibuf->dds_data.nummipmaps = dds.mipmapCount(); | ibuf->dds_data.nummipmaps = dds.mipmapCount(); | ||||
| ▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines | |||||