// //--------------------------------------------------------------------------- // // Copyright(C) 2004-2016 Christoph Oelckers // All rights reserved. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see http://www.gnu.org/licenses/ // //-------------------------------------------------------------------------- // /* ** gl_bitmap.cpp ** Bitmap class for texture composition ** */ #include "v_palette.h" #include "templates.h" #include "gl/textures/gl_translate.h" #include "gl/textures/gl_bitmap.h" #include "gl/system/gl_interface.h" //=========================================================================== // // multi-format pixel copy with colormap application // requires one of the previously defined conversion classes to work // //=========================================================================== template void iCopyColors(unsigned char * pout, const unsigned char * pin, int count, int step, uint8_t tr, uint8_t tg, uint8_t tb) { int i; unsigned char a; for(i=0;i, iCopyColors, iCopyColors, iCopyColors, iCopyColors, iCopyColors, iCopyColors, iCopyColors, iCopyColors, iCopyColors }; //=========================================================================== // // True Color texture copy function // This excludes all the cases that force downconversion to the // base palette because they wouldn't be used anyway. // //=========================================================================== void FGLBitmap::CopyPixelDataRGB(int originx, int originy, const uint8_t * patch, int srcwidth, int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf, int r, int g, int b) { if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate)) { uint8_t *buffer = GetPixels() + 4*originx + Pitch*originy; for (int y=0;y 0) { PalEntry *ptrans = GLTranslationPalette::GetPalette(translation); if (ptrans && !alphatrans) { for (i = 0; i < 256; i++) { penew[i] = (ptrans[i] & 0xffffff) | (palette[i] & 0xff000000); } } else if (ptrans) { memcpy(penew, ptrans, 256 * sizeof(PalEntry)); } } else { memcpy(penew, palette, 256*sizeof(PalEntry)); } // convert the image according to the translated palette. for (y=0;y