#include <SDL.h>
#include "CSLog.h"
#include "SDL_mixer.h"
#include "smpeg.h"
#include <string>
#include "CSMessageDispatchable.h"
#include "CSMessage.h"
Go to the source code of this file.
Data Structures | |
class | SDLMain |
Defines | |
#define | COLOR(src, c) SDL_MapRGB(((src)->format),(((c)&0xff0000)>>16),(((c)&0xff00)>>8),(((c)&0xff))) |
Functions | |
int | convert (const char *start_string, int radix) |
int | _putPixelAlpha (SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color, Uint8 alpha) |
Variables | |
const int | NUM_UPDATE_RECTS = 500 |
|
Definition at line 13 of file SDLMain.h. Referenced by CSRoundedBorder::paint(), CSBorder::paint(), CSGrafikElement::paintAreaStandard(), CSFont::putString(), and CSGame::run(). |
|
|
|
Definition at line 727 of file SDLMain.cpp. References B, clip_xmax, clip_xmin, clip_ymax, clip_ymin, G, LOG_ENTER, LOG_EXIT, and R. Referenced by pixelColorNolock().
00728 { 00729 char *CLASS = "None"; 00730 static char *functionName="_putPixelAlpha"; 00731 LOG_ENTER 00732 00733 Uint32 Rmask = surface->format->Rmask, Gmask = 00734 surface->format->Gmask, Bmask = surface->format->Bmask, Amask = surface->format->Amask; 00735 Uint32 R, G, B, A = 0; 00736 00737 if (x >= clip_xmin(surface) && x <= clip_xmax(surface) 00738 && y >= clip_ymin(surface) && y <= clip_ymax(surface)) { 00739 00740 switch (surface->format->BytesPerPixel) { 00741 case 1:{ /* Assuming 8-bpp */ 00742 if (alpha == 255) { 00743 *((Uint8 *) surface->pixels + y * surface->pitch + x) = color; 00744 } else { 00745 Uint8 *pixel = (Uint8 *) surface->pixels + y * surface->pitch + x; 00746 00747 Uint8 dR = surface->format->palette->colors[*pixel].r; 00748 Uint8 dG = surface->format->palette->colors[*pixel].g; 00749 Uint8 dB = surface->format->palette->colors[*pixel].b; 00750 Uint8 sR = surface->format->palette->colors[color].r; 00751 Uint8 sG = surface->format->palette->colors[color].g; 00752 Uint8 sB = surface->format->palette->colors[color].b; 00753 00754 dR = dR + ((sR - dR) * alpha >> 8); 00755 dG = dG + ((sG - dG) * alpha >> 8); 00756 dB = dB + ((sB - dB) * alpha >> 8); 00757 00758 *pixel = SDL_MapRGB(surface->format, dR, dG, dB); 00759 } 00760 } 00761 break; 00762 00763 case 2:{ /* Probably 15-bpp or 16-bpp */ 00764 if (alpha == 255) { 00765 *((Uint16 *) surface->pixels + y * surface->pitch / 2 + x) = color; 00766 } else { 00767 Uint16 *pixel = (Uint16 *) surface->pixels + y * surface->pitch / 2 + x; 00768 Uint32 dc = *pixel; 00769 00770 R = ((dc & Rmask) + (((color & Rmask) - (dc & Rmask)) * alpha >> 8)) & Rmask; 00771 G = ((dc & Gmask) + (((color & Gmask) - (dc & Gmask)) * alpha >> 8)) & Gmask; 00772 B = ((dc & Bmask) + (((color & Bmask) - (dc & Bmask)) * alpha >> 8)) & Bmask; 00773 if (Amask) 00774 A = ((dc & Amask) + (((color & Amask) - (dc & Amask)) * alpha >> 8)) & Amask; 00775 00776 *pixel = R | G | B | A; 00777 } 00778 } 00779 break; 00780 00781 case 3:{ /* Slow 24-bpp mode, usually not used */ 00782 Uint8 *pix = (Uint8 *) surface->pixels + y * surface->pitch + x * 3; 00783 Uint8 rshift8 = surface->format->Rshift / 8; 00784 Uint8 gshift8 = surface->format->Gshift / 8; 00785 Uint8 bshift8 = surface->format->Bshift / 8; 00786 Uint8 ashift8 = surface->format->Ashift / 8; 00787 00788 00789 if (alpha == 255) { 00790 *(pix + rshift8) = color >> surface->format->Rshift; 00791 *(pix + gshift8) = color >> surface->format->Gshift; 00792 *(pix + bshift8) = color >> surface->format->Bshift; 00793 *(pix + ashift8) = color >> surface->format->Ashift; 00794 } else { 00795 Uint8 dR, dG, dB, dA = 0; 00796 Uint8 sR, sG, sB, sA = 0; 00797 00798 pix = (Uint8 *) surface->pixels + y * surface->pitch + x * 3; 00799 00800 dR = *((pix) + rshift8); 00801 dG = *((pix) + gshift8); 00802 dB = *((pix) + bshift8); 00803 dA = *((pix) + ashift8); 00804 00805 sR = (color >> surface->format->Rshift) & 0xff; 00806 sG = (color >> surface->format->Gshift) & 0xff; 00807 sB = (color >> surface->format->Bshift) & 0xff; 00808 sA = (color >> surface->format->Ashift) & 0xff; 00809 00810 dR = dR + ((sR - dR) * alpha >> 8); 00811 dG = dG + ((sG - dG) * alpha >> 8); 00812 dB = dB + ((sB - dB) * alpha >> 8); 00813 dA = dA + ((sA - dA) * alpha >> 8); 00814 00815 *((pix) + rshift8) = dR; 00816 *((pix) + gshift8) = dG; 00817 *((pix) + bshift8) = dB; 00818 *((pix) + ashift8) = dA; 00819 } 00820 } 00821 break; 00822 00823 case 4:{ /* Probably 32-bpp */ 00824 if (alpha == 255) { 00825 *((Uint32 *) surface->pixels + y * surface->pitch / 4 + x) = color; 00826 } else { 00827 Uint32 *pixel = (Uint32 *) surface->pixels + y * surface->pitch / 4 + x; 00828 Uint32 dc = *pixel; 00829 00830 R = ((dc & Rmask) + (((color & Rmask) - (dc & Rmask)) * alpha >> 8)) & Rmask; 00831 G = ((dc & Gmask) + (((color & Gmask) - (dc & Gmask)) * alpha >> 8)) & Gmask; 00832 B = ((dc & Bmask) + (((color & Bmask) - (dc & Bmask)) * alpha >> 8)) & Bmask; 00833 if (Amask) 00834 A = ((dc & Amask) + (((color & Amask) - (dc & Amask)) * alpha >> 8)) & Amask; 00835 00836 *pixel = R | G | B | A; 00837 } 00838 } 00839 break; 00840 } 00841 } 00842 00843 LOG_EXIT 00844 return (0); 00845 } |
|
Definition at line 14 of file SDLMain.h. Referenced by SDLMain::addUpdateRect(). |