DevIL: /home/dwoods/DevIL/src-IL/include/il_rle.h Source File

- Main Page
- Data Structures
- Files

# /home/dwoods/DevIL/src-IL/include/il_rle.h

    00001 //-----------------------------------------------------------------------------
    00002 //
    00003 // ImageLib Sources
    00004 // Copyright (C) 2000-2002 by Denton Woods
    00005 // Last modified: 05/25/2001 <--Y2K Compliant! =]
    00006 //
    00007 // Filename: src-IL/include/il_rle.h
    00008 //
    00009 // Description: Functions for run-length encoding
    00010 //
    00011 //-----------------------------------------------------------------------------
    00012
    00013 #ifndef RLE_H
    00014 #define RLE_H
    00015
    00016 #include "il_internal.h"
    00017
    00018 #define TGA_MAX_RUN 128
    00019 #define SGI_MAX_RUN 127
    00020 #define BMP_MAX_RUN 127
    00021
    00022 #ifdef IL_RLE_C
    00023 #undef NOINLINE
    00024 #undef INLINE
    00025 #define INLINE
    00026 #endif
    00027
    00028 #ifndef NOINLINE
    00029 INLINE ILuint GetPix(ILubyte *p, ILuint bpp) {
    00030         ILuint Pixel;
    00031         Pixel = (ILuint)*p++;
    00032
    00033         while( bpp-- > 1 ) {
    00034                 Pixel <<= 8;
    00035                 Pixel |= (ILuint)*p++;
    00036         }
    00037         return Pixel;
    00038 }
    00039
    00040 INLINE ILint CountDiffPixels(ILubyte *p, ILuint bpp, ILuint pixCnt) {
    00041         ILuint  pixel;
    00042         ILuint  nextPixel = 0;
    00043         ILint   n;
    00044
    00045         n = 0;
    00046         if (pixCnt == 1)
    00047                 return pixCnt;
    00048         pixel = GetPix(p, bpp);
    00049
    00050         while (pixCnt > 1) {
    00051                 p += bpp;
    00052                 nextPixel = GetPix(p, bpp);
    00053                 if (nextPixel == pixel)
    00054                         break;
    00055                 pixel = nextPixel;
    00056                 ++n;
    00057                 --pixCnt;
    00058         }
    00059
    00060         if (nextPixel == pixel)
    00061                 return n;
    00062         return n + 1;
    00063 }
    00064
    00065
    00066 INLINE ILint CountSamePixels(ILubyte *p, ILuint bpp, ILuint pixCnt) {
    00067         ILuint  pixel;
    00068         ILuint  nextPixel;
    00069         ILint   n;
    00070
    00071         n = 1;
    00072         pixel = GetPix(p, bpp);
    00073         pixCnt--;
    00074
    00075         while (pixCnt > 0) {
    00076                 p += bpp;
    00077                 nextPixel = GetPix(p, bpp);
    00078                 if (nextPixel != pixel)
    00079                         break;
    00080                 ++n;
    00081                 --pixCnt;
    00082         }
    00083
    00084         return n;
    00085 }
    00086 #endif
    00087
    00088 ILuint GetPix(ILubyte *p, ILuint bpp);
    00089 ILint CountDiffPixels(ILubyte *p, ILuint bpp, ILuint pixCnt);
    00090 ILint CountSamePixels(ILubyte *p, ILuint bpp, ILuint pixCnt);
    00091
    00092 #endif//RLE_H