]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
upgraded Image_CopyMux to be able to output constant byte values as well as indexed...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 20 Feb 2004 16:31:03 +0000 (16:31 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 20 Feb 2004 16:31:03 +0000 (16:31 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3911 d7cf8633-e32d-0410-b094-e92efae38249

image.c
image.h

diff --git a/image.c b/image.c
index b46e3f4f91910d39bfb98430590a4132f08a3029..192cb568d9eded768e0ab86197fb6be4b9959d57 100644 (file)
--- a/image.c
+++ b/image.c
@@ -9,7 +9,7 @@ int             image_height;
 
 void Image_CopyMux(qbyte *outpixels, const qbyte *inpixels, int width, int height, int flipx, int flipy, int flipdiagonal, int numincomponents, int numoutcomponents, int *inputcomponentindices)
 {
 
 void Image_CopyMux(qbyte *outpixels, const qbyte *inpixels, int width, int height, int flipx, int flipy, int flipdiagonal, int numincomponents, int numoutcomponents, int *inputcomponentindices)
 {
-       int c, x, y;
+       int index, c, x, y;
        const qbyte *in, *inrow, *incolumn;
        if (flipdiagonal)
        {
        const qbyte *in, *inrow, *incolumn;
        if (flipdiagonal)
        {
@@ -20,7 +20,10 @@ void Image_CopyMux(qbyte *outpixels, const qbyte *inpixels, int width, int heigh
                        {
                                in = incolumn + (flipy ? height - 1 - x : x) * width * numincomponents;
                                for (c = 0;c < numoutcomponents;c++)
                        {
                                in = incolumn + (flipy ? height - 1 - x : x) * width * numincomponents;
                                for (c = 0;c < numoutcomponents;c++)
-                                       *outpixels++ = in[inputcomponentindices[c]];
+                               {
+                                       index = inputcomponentindices[c];
+                                       *outpixels++ = (index & 0x80000000) ? (index - 0x8000000) : in[index];
+                               }
                        }
                }
        }
                        }
                }
        }
@@ -33,7 +36,10 @@ void Image_CopyMux(qbyte *outpixels, const qbyte *inpixels, int width, int heigh
                        {
                                in = inrow + (flipx ? width - 1 - x : x) * numincomponents;
                                for (c = 0;c < numoutcomponents;c++)
                        {
                                in = inrow + (flipx ? width - 1 - x : x) * numincomponents;
                                for (c = 0;c < numoutcomponents;c++)
-                                       *outpixels++ = in[inputcomponentindices[c]];
+                               {
+                                       index = inputcomponentindices[c];
+                                       *outpixels++ = (index & 0x80000000) ? (index - 0x8000000) : in[index];
+                               }
                        }
                }
        }
                        }
                }
        }
diff --git a/image.h b/image.h
index f85a806085f8be2d3361e60e150ef19ddcf12ef1..08b21f0fbd25dbbd907c37289d363c0e54d99b32 100644 (file)
--- a/image.h
+++ b/image.h
@@ -4,6 +4,8 @@
 
 // swizzle components (even converting number of components) and flip images
 // (warning: input must be different than output due to non-linear read/write)
 
 // swizzle components (even converting number of components) and flip images
 // (warning: input must be different than output due to non-linear read/write)
+// (tip: inputcomponentindices can contain values | 0x80000000 to tell it to
+// store them directly into output, so 255 | 0x80000000 would write 255)
 void Image_CopyMux(qbyte *outpixels, const qbyte *inpixels, int width, int height, int flipx, int flipy, int flipdiagonal, int numincomponents, int numoutcomponents, int *inputcomponentindices);
 
 // applies gamma correction to RGB pixels, in can be the same as out
 void Image_CopyMux(qbyte *outpixels, const qbyte *inpixels, int width, int height, int flipx, int flipy, int flipdiagonal, int numincomponents, int numoutcomponents, int *inputcomponentindices);
 
 // applies gamma correction to RGB pixels, in can be the same as out