From 172056e7598d3447c682a694d824041076f3255e Mon Sep 17 00:00:00 2001 From: "chirs241097@gmail.com" Date: Mon, 24 Feb 2014 03:25:05 +0000 Subject: M trunk/CHANGELOG.TXT M trunk/background.h M trunk/effects.h M trunk/global.h M trunk/hge/CxImage/ximagif.cpp M trunk/hge/CxImage/ximaint.cpp M trunk/hge/CxImage/ximapng.cpp M trunk/hge/graphics.cpp M trunk/hge/input.cpp M trunk/hge/resource.cpp M trunk/hge/sound.cpp M trunk/hge/system.cpp M trunk/hgehelp/hgefont.cpp M trunk/levels.h M trunk/libcgh.h M trunk/libcghEx.cpp M trunk/menuitem.cpp M trunk/menuitem.h M trunk/menus.h M trunk/music.h M trunk/scorec.h M trunk/scoresystem.h M trunk/towernbullet.h --- hge/CxImage/ximagif.cpp | 64 ++++++++++++++++++------------------ hge/CxImage/ximaint.cpp | 87 +++++++++++++++++++++++++------------------------ hge/CxImage/ximapng.cpp | 6 ++-- 3 files changed, 79 insertions(+), 78 deletions(-) (limited to 'hge/CxImage') diff --git a/hge/CxImage/ximagif.cpp b/hge/CxImage/ximagif.cpp index b225f47..8c94b9e 100644 --- a/hge/CxImage/ximagif.cpp +++ b/hge/CxImage/ximagif.cpp @@ -95,7 +95,7 @@ bool CxImageGIF::Decode(CxFile *fp) // Global colour map? if (dscgif.pflds & 0x80) fp->Read(TabCol.paleta,sizeof(struct rgb_color)*TabCol.sogct,1); - else + else bTrueColor++; //first chance for a truecolor gif int32_t first_transparent_index = 0; @@ -145,9 +145,9 @@ bool CxImageGIF::Decode(CxFile *fp) if ((iImage==0) && (image.w != dscgif.scrwidth) && (image.h != dscgif.scrheight)) bTrueColor++; - rgb_color locpal[256]; //Local Palette - rgb_color* pcurpal = TabCol.paleta; //Current Palette - int16_t palcount = TabCol.sogct; //Current Palette color count + rgb_color locpal[256]; //Local Palette + rgb_color* pcurpal = TabCol.paleta; //Current Palette + int16_t palcount = TabCol.sogct; //Current Palette color count // Local colour map? if (image.pf & 0x80) { @@ -208,13 +208,13 @@ bool CxImageGIF::Decode(CxFile *fp) if ((image.pf & 0x80) || (dscgif.pflds & 0x80)) { uint8_t r[256], g[256], b[256]; - int32_t i, has_white = 0; + int32_t i;//, has_white = 0; for (i=0; i < palcount; i++) { r[i] = pcurpal[i].r; g[i] = pcurpal[i].g; b[i] = pcurpal[i].b; - if (RGB(r[i],g[i],b[i]) == 0xFFFFFF) has_white = 1; + //if (RGB(r[i],g[i],b[i]) == 0xFFFFFF) has_white = 1; } // Force transparency colour white... @@ -223,7 +223,7 @@ bool CxImageGIF::Decode(CxFile *fp) // Fill in with white // AD if (info.nBkgndIndex >= 0) { while (i < 256) { - has_white = 1; + //has_white = 1; r[i] = g[i] = b[i] = 255; i++; } @@ -579,7 +579,7 @@ void CxImageGIF::EncodeHeader(CxFile *fp) if (head.biClrUsed!=0){ RGBQUAD* pPal = GetPalette(); - for(uint32_t i=0; iPutC(pPal[i].rgbRed); fp->PutC(pPal[i].rgbGreen); @@ -598,7 +598,7 @@ void CxImageGIF::EncodeExtension(CxFile *fp) gifgce.flags |= ((info.nBkgndIndex != -1) ? 1 : 0); gifgce.flags |= ((GetDisposalMethod() & 0x7) << 2); gifgce.delaytime = (uint16_t)info.dwFrameDelay; - gifgce.transpcolindex = (uint8_t)info.nBkgndIndex; + gifgce.transpcolindex = (uint8_t)info.nBkgndIndex; //Invert byte order in case we use a byte order arch, then set it back gifgce.delaytime = m_ntohs(gifgce.delaytime); @@ -618,9 +618,9 @@ void CxImageGIF::EncodeLoopExtension(CxFile *fp) fp->Write("NETSCAPE2.0",11,1); fp->PutC(3); //byte 15 : 3 (hex 0x03) Length of Data Sub-Block (three bytes of data to follow) fp->PutC(1); //byte 16 : 1 (hex 0x01) - Putword(m_loops,fp); //bytes 17 to 18 : 0 to 65535, an unsigned integer in lo-hi byte format. + Putword(m_loops,fp); //bytes 17 to 18 : 0 to 65535, an unsigned integer in lo-hi byte format. //This indicate the number of iterations the loop should be executed. - fp->PutC(0); //bytes 19 : 0 (hex 0x00) a Data Sub-block Terminator. + fp->PutC(0); //bytes 19 : 0 (hex 0x00) a Data Sub-block Terminator. } //////////////////////////////////////////////////////////////////////////////// void CxImageGIF::EncodeBody(CxFile *fp, bool bLocalColorMap) @@ -643,7 +643,7 @@ void CxImageGIF::EncodeBody(CxFile *fp, bool bLocalColorMap) if (bLocalColorMap){ Flags|=0x87; RGBQUAD* pPal = GetPalette(); - for(uint32_t i=0; iPutC(pPal[i].rgbRed); fp->PutC(pPal[i].rgbGreen); @@ -778,12 +778,12 @@ void CxImageGIF::compressNONE( int32_t init_bits, CxFile* outfile) output( (code_int)ClearCode ); - while ( ent != EOF ) { + while ( ent != EOF ) { c = GifNextPixel(); output ( (code_int) ent ); ent = c; - if ( free_ent < maxmaxcode ) { + if ( free_ent < maxmaxcode ) { free_ent++; } else { free_ent=(int16_t)(ClearCode+2); @@ -834,7 +834,7 @@ void CxImageGIF::compressLZW( int32_t init_bits, CxFile* outfile) cl_hash((int32_t)HSIZE); /* clear hash table */ output( (code_int)ClearCode ); - while ( (c = GifNextPixel( )) != EOF ) { + while ( (c = GifNextPixel( )) != EOF ) { fcode = (int32_t) (((int32_t) c << MAXBITSCODES) + ent); i = (((code_int)c << hshift) ^ ent); /* xor hashing */ @@ -853,7 +853,7 @@ probe: nomatch: output ( (code_int) ent ); ent = c; - if ( free_ent < maxmaxcode ) { + if ( free_ent < maxmaxcode ) { CodeTabOf (i) = free_ent++; /* code -> hashtable */ HashTabOf (i) = fcode; } else { @@ -909,7 +909,7 @@ void CxImageGIF::output( code_int code) maxcode = (int16_t)MAXCODE(n_bits); } } - + if( code == EOFCode ) { // At EOF, write the rest of the buffer. while( cur_bits > 0 ) { @@ -917,7 +917,7 @@ void CxImageGIF::output( code_int code) cur_accum >>= 8; cur_bits -= 8; } - + flush_char(); g_outfile->Flush(); @@ -953,7 +953,7 @@ void CxImageGIF::cl_hash(int32_t hsize) *(htab_p-3)=m1; *(htab_p-2)=m1; *(htab_p-1)=m1; - + htab_p-=16; } while ((i-=16) >=0); @@ -1334,7 +1334,7 @@ int32_t CxImageGIF::get_num_frames(CxFile *fp,struct_TabCol* TabColSrc,struct_ds } else { fp->Seek(-(ibfmax - ibf - 1), SEEK_CUR); } - + break; } case ';': //terminator @@ -1411,22 +1411,22 @@ void CxImageGIF::GifMix(CxImage & imgsrc2, struct_image & imgdesc) * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting - * documentation. This software is provided "AS IS." The Hutchison Avenue - * Software Corporation disclaims all warranties, either express or implied, - * including but not limited to implied warranties of merchantability and + * documentation. This software is provided "AS IS." The Hutchison Avenue + * Software Corporation disclaims all warranties, either express or implied, + * including but not limited to implied warranties of merchantability and * fitness for a particular purpose, with respect to this code and accompanying - * documentation. - * - * The miGIF compression routines do not, strictly speaking, generate files - * conforming to the GIF spec, since the image data is not LZW-compressed - * (this is the point: in order to avoid transgression of the Unisys patent - * on the LZW algorithm.) However, miGIF generates data streams that any + * documentation. + * + * The miGIF compression routines do not, strictly speaking, generate files + * conforming to the GIF spec, since the image data is not LZW-compressed + * (this is the point: in order to avoid transgression of the Unisys patent + * on the LZW algorithm.) However, miGIF generates data streams that any * reasonably sane LZW decompresser will decompress to what we want. * - * miGIF compression uses run length encoding. It compresses horizontal runs + * miGIF compression uses run length encoding. It compresses horizontal runs * of pixels of the same color. This type of compression gives good results - * on images with many runs, for example images with lines, text and solid - * shapes on a solid-colored background. It gives little or no compression + * on images with many runs, for example images with lines, text and solid + * shapes on a solid-colored background. It gives little or no compression * on images with few runs, for example digital or scanned photos. * * der Mouse diff --git a/hge/CxImage/ximaint.cpp b/hge/CxImage/ximaint.cpp index 0acedff..5f93038 100644 --- a/hge/CxImage/ximaint.cpp +++ b/hge/CxImage/ximaint.cpp @@ -1,5 +1,5 @@ // xImaInt.cpp : interpolation functions -/* 02/2004 - Branko Brevensek +/* 02/2004 - Branko Brevensek * CxImage version 7.0.0 31/Dec/2010 - Davide Pizzolato - www.xdp.it */ @@ -15,7 +15,7 @@ * * \param x, y - coordinates of pixel * \param ofMethod - overflow method - * + * * \return x, y - new coordinates (pixel (x,y) now lies inside image) * * \author ***bd*** 2.2004 @@ -50,7 +50,7 @@ void CxImage::OverflowCoordinates(int32_t &x, int32_t &y, OverflowMethod const o //////////////////////////////////////////////////////////////////////////////// /** - * See OverflowCoordinates for integer version + * See OverflowCoordinates for integer version * \author ***bd*** 2.2004 */ void CxImage::OverflowCoordinates(float &x, float &y, OverflowMethod const ofMethod) @@ -162,14 +162,14 @@ RGBQUAD CxImage::GetPixelColorWithOverflow(int32_t x, int32_t y, OverflowMethod * as (1,1). Center of first pixel is at (0,0) and center of pixel right to it is (1,0). * (0.5,0) is half way between these two pixels. * \param inMethod - interpolation (reconstruction) method (kernel) to use: - * - IM_NEAREST_NEIGHBOUR - returns colour of nearest lying pixel (causes stairy look of + * - IM_NEAREST_NEIGHBOUR - returns colour of nearest lying pixel (causes stairy look of * processed images) * - IM_BILINEAR - interpolates colour from four neighbouring pixels (softens image a bit) * - IM_BICUBIC - interpolates from 16 neighbouring pixels (can produce "halo" artifacts) - * - IM_BICUBIC2 - interpolates from 16 neighbouring pixels (perhaps a bit less halo artifacts + * - IM_BICUBIC2 - interpolates from 16 neighbouring pixels (perhaps a bit less halo artifacts than IM_BICUBIC) * - IM_BSPLINE - interpolates from 16 neighbouring pixels (softens image, washes colours) - * (As far as I know, image should be prefiltered for this method to give + * (As far as I know, image should be prefiltered for this method to give * good results... some other time :) ) * This method uses bicubic interpolation kernel from CXImage 5.99a and older * versions. @@ -180,13 +180,13 @@ RGBQUAD CxImage::GetPixelColorWithOverflow(int32_t x, int32_t y, OverflowMethod * (and other modes if colour can't calculated in a specified way) * * \return interpolated color value (including interpolated alpha value, if image has alpha layer) - * + * * \author ***bd*** 2.2004 */ RGBQUAD CxImage::GetPixelColorInterpolated( - float x,float y, - InterpolationMethod const inMethod, - OverflowMethod const ofMethod, + float x,float y, + InterpolationMethod const inMethod, + OverflowMethod const ofMethod, RGBQUAD* const rplColor) { //calculate nearest pixel @@ -224,8 +224,8 @@ RGBQUAD CxImage::GetPixelColorInterpolated( wbb=wa*(*pxptr++); wgg=wa*(*pxptr++); wrr=wa*(*pxptr++); wbb+=wb*(*pxptr++); wgg+=wb*(*pxptr++); wrr+=wb*(*pxptr); pxptr+=(info.dwEffWidth-5); //move to next row - wbb+=wc*(*pxptr++); wgg+=wc*(*pxptr++); wrr+=wc*(*pxptr++); - wbb+=wd*(*pxptr++); wgg+=wd*(*pxptr++); wrr+=wd*(*pxptr); + wbb+=wc*(*pxptr++); wgg+=wc*(*pxptr++); wrr+=wc*(*pxptr++); + wbb+=wd*(*pxptr++); wgg+=wd*(*pxptr++); wrr+=wd*(*pxptr); color.rgbRed=(uint8_t) (wrr>>8); color.rgbGreen=(uint8_t) (wgg>>8); color.rgbBlue=(uint8_t) (wbb>>8); #if CXIMAGE_SUPPORT_ALPHA if (pAlpha) { @@ -266,7 +266,7 @@ RGBQUAD CxImage::GetPixelColorInterpolated( return color; }//if }//default - case IM_BICUBIC: + case IM_BICUBIC: case IM_BICUBIC2: case IM_BSPLINE: case IM_BOX: @@ -393,7 +393,8 @@ RGBQUAD CxImage::GetPixelColorInterpolated( kernelx[i]=KernelPower((float)(xi+i-1-x)); kernely[i]=KernelPower((float)(yi+i-1-y)); }//for i - break; + break; + default:break; }//switch rr=gg=bb=aa=0; if (((xi+2)=1 && ((yi+2)=1) && !IsIndexed()) { @@ -519,7 +520,7 @@ RGBQUAD CxImage::GetPixelColorInterpolated( if (gg>255) gg=255; if (gg<0) gg=0; color.rgbGreen=(uint8_t) gg; if (bb>255) bb=255; if (bb<0) bb=0; color.rgbBlue=(uint8_t) bb; #if CXIMAGE_SUPPORT_ALPHA - if (aa>255) aa=255; if (aa<0) aa=0; color.rgbReserved=(uint8_t) aa; + if (aa>255) aa=255; if (aa<0) aa=0; color.rgbReserved=(uint8_t) aa; #else color.rgbReserved = 0; #endif @@ -542,12 +543,12 @@ void CxImage::AddAveragingCont(RGBQUAD const &color, float const surf, float &rr } //////////////////////////////////////////////////////////////////////////////// /** - * This method is similar to GetPixelColorInterpolated, but this method also properly handles + * This method is similar to GetPixelColorInterpolated, but this method also properly handles * subsampling. - * If you need to sample original image with interval of more than 1 pixel (as when shrinking an image), + * If you need to sample original image with interval of more than 1 pixel (as when shrinking an image), * you should use this method instead of GetPixelColorInterpolated or aliasing will occur. * When area width and height are both less than pixel, this method gets pixel color by interpolating - * color of frame center with selected (inMethod) interpolation by calling GetPixelColorInterpolated. + * color of frame center with selected (inMethod) interpolation by calling GetPixelColorInterpolated. * If width and height are more than 1, method calculates color by averaging color of pixels within area. * Interpolation method is not used in this case. Pixel color is interpolated by averaging instead. * If only one of both is more than 1, method uses combination of interpolation and averaging. @@ -555,7 +556,7 @@ void CxImage::AddAveragingCont(RGBQUAD const &color, float const surf, float &rr * between IM_BILINEAR (perhaps best for this case) and better methods. IM_NEAREST_NEIGHBOUR again * leads to aliasing artifacts. * This method is a bit slower than GetPixelColorInterpolated and when aliasing is not a problem, you should - * simply use the later. + * simply use the later. * * \param xc, yc - center of (rectangular) area * \param w, h - width and height of area @@ -566,13 +567,13 @@ void CxImage::AddAveragingCont(RGBQUAD const &color, float const surf, float &rr * \author ***bd*** 2.2004 */ RGBQUAD CxImage::GetAreaColorInterpolated( - float const xc, float const yc, float const w, float const h, - InterpolationMethod const inMethod, - OverflowMethod const ofMethod, + float const xc, float const yc, float const w, float const h, + InterpolationMethod const inMethod, + OverflowMethod const ofMethod, RGBQUAD* const rplColor) { RGBQUAD color; //calculated colour - + if (h<=1 && w<=1) { //both width and height are less than one... we will use interpolation of center point return GetPixelColorInterpolated(xc, yc, inMethod, ofMethod, rplColor); @@ -581,11 +582,11 @@ RGBQUAD CxImage::GetAreaColorInterpolated( CxRect2 area(xc-w/2.0f, yc-h/2.0f, xc+w/2.0f, yc+h/2.0f); //area int32_t xi1=(int32_t)(area.botLeft.x+0.49999999f); //low x int32_t yi1=(int32_t)(area.botLeft.y+0.49999999f); //low y - - + + int32_t xi2=(int32_t)(area.topRight.x+0.5f); //top x int32_t yi2=(int32_t)(area.topRight.y+0.5f); //top y (for loops) - + float rr,gg,bb,aa; //red, green, blue and alpha components rr=gg=bb=aa=0; int32_t x,y; //loop counters @@ -601,7 +602,7 @@ RGBQUAD CxImage::GetAreaColorInterpolated( hBL=intBL.Height(); //height of bottom left... wTR=intTR.Width(); //width of top right... hTR=intTR.Height(); //height of top right... - + AddAveragingCont(GetPixelColorWithOverflow(xi1,yi1,ofMethod,rplColor), wBL*hBL, rr, gg, bb, aa); //bottom left pixel AddAveragingCont(GetPixelColorWithOverflow(xi2,yi1,ofMethod,rplColor), wTR*hBL, rr, gg, bb, aa); //bottom right pixel AddAveragingCont(GetPixelColorWithOverflow(xi1,yi2,ofMethod,rplColor), wBL*hTR, rr, gg, bb, aa); //top left pixel @@ -617,7 +618,7 @@ RGBQUAD CxImage::GetAreaColorInterpolated( AddAveragingCont(GetPixelColorWithOverflow(xi2,y,ofMethod,rplColor), wTR, rr, gg, bb, aa); //right column } for (y=yi1+1; y255) rr=255; if (rr<0) rr=0; color.rgbRed=(uint8_t) rr; @@ -673,7 +674,7 @@ float CxImage::KernelBSpline(const float x) if ((xp2) <= 0.0f) a = 0.0f; else a = xp2*xp2*xp2; // Only float, not float -> double -> float if ((xp1) <= 0.0f) b = 0.0f; else b = xp1*xp1*xp1; - if (x <= 0) c = 0.0f; else c = x*x*x; + if (x <= 0) c = 0.0f; else c = x*x*x; if ((xm1) <= 0.0f) d = 0.0f; else d = xm1*xm1*xm1; return (0.16666666666666666667f * (a - (4.0f * b) + (6.0f * c) - (4.0f * d))); @@ -710,7 +711,7 @@ float CxImage::KernelLinear(const float t) // if (0<=t && t<=1) return 1-t; // if (-1<=t && t<0) return 1+t; // return 0; - + // if (t < -1.0f) return 0.0f; @@ -841,9 +842,9 @@ float CxImage::KernelBlackman(const float x) float CxImage::KernelBessel_J1(const float x) { double p, q; - + register int32_t i; - + static const double Pone[] = { @@ -869,7 +870,7 @@ float CxImage::KernelBessel_J1(const float x) 0.1606931573481487801970916749e+4, 0.1e+1 }; - + p = Pone[8]; q = Qone[8]; for (i=7; i >= 0; i--) @@ -883,9 +884,9 @@ float CxImage::KernelBessel_J1(const float x) float CxImage::KernelBessel_P1(const float x) { double p, q; - + register int32_t i; - + static const double Pone[] = { @@ -905,7 +906,7 @@ float CxImage::KernelBessel_P1(const float x) 0.2030775189134759322293574e+3, 0.1e+1 }; - + p = Pone[5]; q = Qone[5]; for (i=4; i >= 0; i--) @@ -919,9 +920,9 @@ float CxImage::KernelBessel_P1(const float x) float CxImage::KernelBessel_Q1(const float x) { double p, q; - + register int32_t i; - + static const double Pone[] = { @@ -941,7 +942,7 @@ float CxImage::KernelBessel_Q1(const float x) 0.1038187585462133728776636e+3, 0.1e+1 }; - + p = Pone[5]; q = Qone[5]; for (i=4; i >= 0; i--) @@ -955,7 +956,7 @@ float CxImage::KernelBessel_Q1(const float x) float CxImage::KernelBessel_Order1(float x) { float p, q; - + if (x == 0.0) return (0.0f); p = x; @@ -1006,7 +1007,7 @@ float CxImage::KernelMitchell(const float x) #define KM_Q1 ((-12.0f * KM_B - 48.0f * KM_C) / 6.0f) #define KM_Q2 (( 6.0f * KM_B + 30.0f * KM_C) / 6.0f) #define KM_Q3 (( -1.0f * KM_B - 6.0f * KM_C) / 6.0f) - + if (x < -2.0) return(0.0f); if (x < -1.0) diff --git a/hge/CxImage/ximapng.cpp b/hge/CxImage/ximapng.cpp index b732491..2e39d1b 100644 --- a/hge/CxImage/ximapng.cpp +++ b/hge/CxImage/ximapng.cpp @@ -85,7 +85,7 @@ bool CxImagePNG::Decode(CxFile *hFile) png_read_info(png_ptr, info_ptr); png_uint_32 _width,_height; - int _bit_depth,_color_type,_interlace_type,_compression_type,_filter_type; + int _bit_depth,_color_type,_interlace_type/*,_compression_type,_filter_type*/; #if PNG_LIBPNG_VER > 10399 png_get_IHDR(png_ptr,info_ptr,&_width,&_height,&_bit_depth,&_color_type, &_interlace_type,&_compression_type,&_filter_type); @@ -95,8 +95,8 @@ bool CxImagePNG::Decode(CxFile *hFile) _bit_depth=info_ptr->bit_depth; _color_type=info_ptr->color_type; _interlace_type=info_ptr->interlace_type; - _compression_type=info_ptr->compression_type; - _filter_type=info_ptr->filter_type; + //_compression_type=info_ptr->compression_type; + //_filter_type=info_ptr->filter_type; #endif if (info.nEscape == -1){ -- cgit v1.2.3