Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Mein <mein@cs.umn.edu>2007-10-12 20:09:59 +0400
committerKent Mein <mein@cs.umn.edu>2007-10-12 20:09:59 +0400
commit6fe98f19a95117633684b85073b4d90654e159fd (patch)
tree50d54508e6e4395442fb486d96cb7202a871ee5e /source/blender/imbuf/intern/dds/dds_api.cpp
parent3697e0852467a29223a59d2ad6a31a00cfbde529 (diff)
This is patch [#7483] imbuf support for uncompressed DDS images
provided by Amorilia NVIDIA updated the dds stuff so we get a nice new patch. Kent
Diffstat (limited to 'source/blender/imbuf/intern/dds/dds_api.cpp')
-rw-r--r--source/blender/imbuf/intern/dds/dds_api.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp
index 0e06fd3e50b..3de30b9f183 100644
--- a/source/blender/imbuf/intern/dds/dds_api.cpp
+++ b/source/blender/imbuf/intern/dds/dds_api.cpp
@@ -28,8 +28,8 @@
#include <dds_api.h>
#include <Stream.h>
#include <DirectDrawSurface.h>
-
#include <stdio.h> // printf
+#include <fstream>
extern "C" {
@@ -39,12 +39,24 @@ extern "C" {
#include "IMB_imbuf.h"
#include "IMB_allocimbuf.h"
-/* not supported yet
+
short imb_save_dds(struct ImBuf * ibuf, char *name, int flags)
{
- return(0);
+ return(0); /* todo: finish this function */
+
+ /* check image buffer */
+ if (ibuf == 0) return (0);
+ if (ibuf->rect == 0) return (0);
+
+ /* open file for writing */
+ std::ofstream fildes(name);
+
+ /* write header */
+ fildes << "DDS ";
+ fildes.close();
+
+ return(1);
}
-*/
int imb_is_a_dds(unsigned char *mem) // note: use at most first 32 bytes
{
@@ -60,7 +72,7 @@ struct ImBuf *imb_load_dds(unsigned char *mem, int size, int flags)
{
struct ImBuf * ibuf = 0;
DirectDrawSurface dds(mem, size); /* reads header */
- unsigned char bytes_per_pixel;
+ unsigned char bits_per_pixel;
unsigned int *rect;
Image img;
unsigned int numpixels = 0;
@@ -85,9 +97,9 @@ struct ImBuf *imb_load_dds(unsigned char *mem, int size, int flags)
}
/* convert DDS into ImBuf */
- if (dds.hasAlpha()) bytes_per_pixel = 32;
- else bytes_per_pixel = 24;
- ibuf = IMB_allocImBuf(dds.width(), dds.height(), bytes_per_pixel, 0, 0);
+ if (dds.hasAlpha()) bits_per_pixel = 32;
+ else bits_per_pixel = 24;
+ ibuf = IMB_allocImBuf(dds.width(), dds.height(), bits_per_pixel, 0, 0);
if (ibuf == 0) return(0); /* memory allocation failed */
ibuf->ftype = DDS;
@@ -107,7 +119,7 @@ struct ImBuf *imb_load_dds(unsigned char *mem, int size, int flags)
cp[0] = pixel.r; /* set R component of col */
cp[1] = pixel.g; /* set G component of col */
cp[2] = pixel.b; /* set B component of col */
- if (bytes_per_pixel == 32)
+ if (bits_per_pixel == 32)
cp[3] = pixel.a; /* set A component of col */
rect[i] = col;
}