| | 140 | case(GL_BGR): |
| | 141 | switch(dest_pixelFormat) |
| | 142 | { |
| | 143 | case(GL_LUMINANCE): |
| | 144 | case(GL_ALPHA): BGR_to_A(num, source, dest); break; |
| | 145 | case(GL_LUMINANCE_ALPHA): BGR_to_LA(num, source, dest); break; |
| | 146 | case(GL_RGB): BGR_to_RGB(num, source, dest); break; |
| | 147 | case(GL_RGBA): BGR_to_RGBA(num, source, dest); break; |
| | 148 | } |
| | 149 | break; |
| | 150 | case(GL_BGRA): |
| | 151 | switch(dest_pixelFormat) |
| | 152 | { |
| | 153 | case(GL_LUMINANCE): |
| | 154 | case(GL_ALPHA): BGRA_to_A(num, source, dest); break; |
| | 155 | case(GL_LUMINANCE_ALPHA): BGRA_to_LA(num, source, dest); break; |
| | 156 | case(GL_RGB): BGRA_to_RGB(num, source, dest); break; |
| | 157 | case(GL_RGBA): BGRA_to_RGBA(num, source, dest); break; |
| | 158 | } |
| | 159 | break; |
| | 333 | |
| | 334 | /////////////////////////////////////////////////////////////////////////////// |
| | 335 | // BGR sources.. |
| | 336 | virtual void BGR_to_A(unsigned int num, unsigned char* source, unsigned char* dest) const |
| | 337 | { |
| | 338 | for(unsigned int i=0;i<num;++i) |
| | 339 | { |
| | 340 | unsigned char val = *source; |
| | 341 | *dest++ = val; |
| | 342 | source += 3; |
| | 343 | } |
| | 344 | } |
| | 345 | |
| | 346 | virtual void BGR_to_LA(unsigned int num, unsigned char* source, unsigned char* dest) const |
| | 347 | { |
| | 348 | for(unsigned int i=0;i<num;++i) |
| | 349 | { |
| | 350 | unsigned char val = *source; |
| | 351 | *dest++ = val; |
| | 352 | *dest++ = val; |
| | 353 | source += 3; |
| | 354 | } |
| | 355 | } |
| | 356 | |
| | 357 | virtual void BGR_to_RGB(unsigned int num, unsigned char* source, unsigned char* dest) const |
| | 358 | { |
| | 359 | for(unsigned int i=0;i<num;++i) |
| | 360 | { |
| | 361 | unsigned char blue = *source++; |
| | 362 | unsigned char green = *source++; |
| | 363 | unsigned char red = *source++; |
| | 364 | *dest++ = red; |
| | 365 | *dest++ = green; |
| | 366 | *dest++ = blue; |
| | 367 | } |
| | 368 | } |
| | 369 | |
| | 370 | virtual void BGR_to_RGBA(unsigned int num, unsigned char* source, unsigned char* dest) const |
| | 371 | { |
| | 372 | for(unsigned int i=0;i<num;++i) |
| | 373 | { |
| | 374 | unsigned char blue = *source++; |
| | 375 | unsigned char green = *source++; |
| | 376 | unsigned char red = *source++; |
| | 377 | unsigned char val = (unsigned char)((int(red)+int(green)+int(blue))/3); |
| | 378 | *dest++ = red; |
| | 379 | *dest++ = green; |
| | 380 | *dest++ = blue; |
| | 381 | *dest++ = val; |
| | 382 | } |
| | 383 | } |
| | 384 | |
| | 385 | /////////////////////////////////////////////////////////////////////////////// |
| | 386 | // BGRA sources.. |
| | 387 | virtual void BGRA_to_A(unsigned int num, unsigned char* source, unsigned char* dest) const |
| | 388 | { |
| | 389 | for(unsigned int i=0;i<num;++i) |
| | 390 | { |
| | 391 | source += 3; |
| | 392 | *dest++ = *source++; |
| | 393 | } |
| | 394 | } |
| | 395 | |
| | 396 | virtual void BGRA_to_LA(unsigned int num, unsigned char* source, unsigned char* dest) const |
| | 397 | { |
| | 398 | for(unsigned int i=0;i<num;++i) |
| | 399 | { |
| | 400 | unsigned char val = *source; |
| | 401 | source += 3; |
| | 402 | *dest++ = val; |
| | 403 | *dest++ = *source++; |
| | 404 | } |
| | 405 | } |
| | 406 | |
| | 407 | virtual void BGRA_to_RGB(unsigned int num, unsigned char* source, unsigned char* dest) const |
| | 408 | { |
| | 409 | for(unsigned int i=0;i<num;++i) |
| | 410 | { |
| | 411 | unsigned char blue = *source++; |
| | 412 | unsigned char green = *source++; |
| | 413 | unsigned char red = *source++; |
| | 414 | *dest++ = red; |
| | 415 | *dest++ = green; |
| | 416 | *dest++ = blue; |
| | 417 | ++source; |
| | 418 | } |
| | 419 | } |
| | 420 | |
| | 421 | virtual void BGRA_to_RGBA(unsigned int num, unsigned char* source, unsigned char* dest) const |
| | 422 | { |
| | 423 | for(unsigned int i=0;i<num;++i) |
| | 424 | { |
| | 425 | unsigned char blue = *source++; |
| | 426 | unsigned char green = *source++; |
| | 427 | unsigned char red = *source++; |
| | 428 | unsigned char alpha = *source++; |
| | 429 | *dest++ = red; |
| | 430 | *dest++ = green; |
| | 431 | *dest++ = blue; |
| | 432 | *dest++ = alpha; |
| | 433 | } |
| | 434 | } |
| | 435 | |