/* ** Command & Conquer Renegade(tm) ** Copyright 2025 Electronic Arts Inc. ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU 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 General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include "bitmaphandler.h" #include "wwdebug.h" void Bitmap_Assert(bool condition) { WWASSERT(condition); } void BitmapHandlerClass::Create_Mipmap_B8G8R8A8( unsigned char* dest_surface, unsigned dest_surface_pitch, unsigned char* src_surface, unsigned src_surface_pitch, unsigned width, unsigned height) { unsigned src_pitch=src_surface_pitch/4; for (unsigned y=0;y1 ) ? 63 : 127; switch(dest_surface_format) { case WW3D_FORMAT_U8V8: *dest_ptr++ = (unsigned char)iDu; *dest_ptr++ = (unsigned char)iDv; break; case WW3D_FORMAT_L6V5U5: *(unsigned short*)dest_ptr = (unsigned short)( ( (iDu>>3) & 0x1f ) << 0 ); *(unsigned short*)dest_ptr |= (unsigned short)( ( (iDv>>3) & 0x1f ) << 5 ); *(unsigned short*)dest_ptr |= (unsigned short)( ( ( uL>>2) & 0x3f ) << 10 ); dest_ptr += 2; break; case WW3D_FORMAT_X8L8V8U8: *dest_ptr++ = (unsigned char)iDu; *dest_ptr++ = (unsigned char)iDv; *dest_ptr++ = (unsigned char)uL; *dest_ptr++ = (unsigned char)0L; break; default: WWASSERT(0); // Unknown bumpmap format break; } // Move one pixel to the left (src is 32-bpp) src_ptr_mid+=src_bpp; src_ptr_prev_line+=src_bpp; src_ptr_next_line+=src_bpp; } } return; } if (src_surface_format==dest_surface_format && (src_surface_format==WW3D_FORMAT_A8R8G8B8 || src_surface_format==WW3D_FORMAT_X8R8G8B8)) { // One-to-one copy or scaling? dest_surface_pitch/=4; src_surface_pitch/=4; if (dest_surface_width==src_surface_width && dest_surface_height==src_surface_height) { // Generate the next mip level while copying the current surface? if (generate_mip_level) { if (dest_surface_width==1) { *(unsigned*)dest_surface=*(unsigned*)src_surface; } else { for (unsigned y=0;y