Lines Matching refs:format
40 SDL_PixelFormat *format; in SDL_AllocFormat() local
44 format = SDL_malloc(sizeof(*format)); in SDL_AllocFormat()
45 if ( format == NULL ) { in SDL_AllocFormat()
49 SDL_memset(format, 0, sizeof(*format)); in SDL_AllocFormat()
50 format->alpha = SDL_ALPHA_OPAQUE; in SDL_AllocFormat()
53 format->BitsPerPixel = bpp; in SDL_AllocFormat()
54 format->BytesPerPixel = (bpp+7)/8; in SDL_AllocFormat()
56 format->palette = NULL; in SDL_AllocFormat()
57 format->Rshift = 0; in SDL_AllocFormat()
58 format->Rloss = 8; in SDL_AllocFormat()
61 ++format->Rshift; in SDL_AllocFormat()
63 --format->Rloss; in SDL_AllocFormat()
65 format->Gshift = 0; in SDL_AllocFormat()
66 format->Gloss = 8; in SDL_AllocFormat()
69 ++format->Gshift; in SDL_AllocFormat()
71 --format->Gloss; in SDL_AllocFormat()
73 format->Bshift = 0; in SDL_AllocFormat()
74 format->Bloss = 8; in SDL_AllocFormat()
77 ++format->Bshift; in SDL_AllocFormat()
79 --format->Bloss; in SDL_AllocFormat()
81 format->Ashift = 0; in SDL_AllocFormat()
82 format->Aloss = 8; in SDL_AllocFormat()
85 ++format->Ashift; in SDL_AllocFormat()
87 --format->Aloss; in SDL_AllocFormat()
89 format->Rmask = Rmask; in SDL_AllocFormat()
90 format->Gmask = Gmask; in SDL_AllocFormat()
91 format->Bmask = Bmask; in SDL_AllocFormat()
92 format->Amask = Amask; in SDL_AllocFormat()
97 format->Rloss = 8-(bpp/3); in SDL_AllocFormat()
98 format->Gloss = 8-(bpp/3)-(bpp%3); in SDL_AllocFormat()
99 format->Bloss = 8-(bpp/3); in SDL_AllocFormat()
100 format->Rshift = ((bpp/3)+(bpp%3))+(bpp/3); in SDL_AllocFormat()
101 format->Gshift = (bpp/3); in SDL_AllocFormat()
102 format->Bshift = 0; in SDL_AllocFormat()
103 format->Rmask = ((0xFF>>format->Rloss)<<format->Rshift); in SDL_AllocFormat()
104 format->Gmask = ((0xFF>>format->Gloss)<<format->Gshift); in SDL_AllocFormat()
105 format->Bmask = ((0xFF>>format->Bloss)<<format->Bshift); in SDL_AllocFormat()
108 format->Rloss = 8; in SDL_AllocFormat()
109 format->Gloss = 8; in SDL_AllocFormat()
110 format->Bloss = 8; in SDL_AllocFormat()
111 format->Aloss = 8; in SDL_AllocFormat()
112 format->Rshift = 0; in SDL_AllocFormat()
113 format->Gshift = 0; in SDL_AllocFormat()
114 format->Bshift = 0; in SDL_AllocFormat()
115 format->Ashift = 0; in SDL_AllocFormat()
116 format->Rmask = 0; in SDL_AllocFormat()
117 format->Gmask = 0; in SDL_AllocFormat()
118 format->Bmask = 0; in SDL_AllocFormat()
119 format->Amask = 0; in SDL_AllocFormat()
126 format->palette = (SDL_Palette *)SDL_malloc(sizeof(SDL_Palette)); in SDL_AllocFormat()
127 if ( format->palette == NULL ) { in SDL_AllocFormat()
128 SDL_FreeFormat(format); in SDL_AllocFormat()
132 (format->palette)->ncolors = ncolors; in SDL_AllocFormat()
133 (format->palette)->colors = (SDL_Color *)SDL_malloc( in SDL_AllocFormat()
134 (format->palette)->ncolors*sizeof(SDL_Color)); in SDL_AllocFormat()
135 if ( (format->palette)->colors == NULL ) { in SDL_AllocFormat()
136 SDL_FreeFormat(format); in SDL_AllocFormat()
150 Rw=8-format->Rloss; in SDL_AllocFormat()
151 for(i=format->Rloss;i>0;i-=Rw) in SDL_AllocFormat()
159 Gw=8-format->Gloss; in SDL_AllocFormat()
160 for(i=format->Gloss;i>0;i-=Gw) in SDL_AllocFormat()
168 Bw=8-format->Bloss; in SDL_AllocFormat()
169 for(i=format->Bloss;i>0;i-=Bw) in SDL_AllocFormat()
178 Aw=8-format->Aloss; in SDL_AllocFormat()
179 for(i=format->Aloss;i>0;i-=Aw) in SDL_AllocFormat()
188 r=(i&Rmask)>>format->Rshift; in SDL_AllocFormat()
189 r=(r<<format->Rloss)|((r*Rm)>>Rw); in SDL_AllocFormat()
190 format->palette->colors[i].r=r; in SDL_AllocFormat()
192 g=(i&Gmask)>>format->Gshift; in SDL_AllocFormat()
193 g=(g<<format->Gloss)|((g*Gm)>>Gw); in SDL_AllocFormat()
194 format->palette->colors[i].g=g; in SDL_AllocFormat()
196 b=(i&Bmask)>>format->Bshift; in SDL_AllocFormat()
197 b=(b<<format->Bloss)|((b*Bm)>>Bw); in SDL_AllocFormat()
198 format->palette->colors[i].b=b; in SDL_AllocFormat()
201 a=(i&Amask)>>format->Ashift; in SDL_AllocFormat()
202 a=(a<<format->Aloss)|((a*Am)>>Aw); in SDL_AllocFormat()
203 format->palette->colors[i].unused=a; in SDL_AllocFormat()
205 format->palette->colors[i].unused=0; in SDL_AllocFormat()
210 format->palette->colors[0].r = 0xFF; in SDL_AllocFormat()
211 format->palette->colors[0].g = 0xFF; in SDL_AllocFormat()
212 format->palette->colors[0].b = 0xFF; in SDL_AllocFormat()
213 format->palette->colors[1].r = 0x00; in SDL_AllocFormat()
214 format->palette->colors[1].g = 0x00; in SDL_AllocFormat()
215 format->palette->colors[1].b = 0x00; in SDL_AllocFormat()
218 SDL_memset((format->palette)->colors, 0, in SDL_AllocFormat()
219 (format->palette)->ncolors*sizeof(SDL_Color)); in SDL_AllocFormat()
222 return(format); in SDL_AllocFormat()
227 if ( surface->format ) { in SDL_ReallocFormat()
228 SDL_FreeFormat(surface->format); in SDL_ReallocFormat()
231 surface->format = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask); in SDL_ReallocFormat()
232 return surface->format; in SDL_ReallocFormat()
251 void SDL_FreeFormat(SDL_PixelFormat *format) in SDL_FreeFormat() argument
253 if ( format ) { in SDL_FreeFormat()
254 if ( format->palette ) { in SDL_FreeFormat()
255 if ( format->palette->colors ) { in SDL_FreeFormat()
256 SDL_free(format->palette->colors); in SDL_FreeFormat()
258 SDL_free(format->palette); in SDL_FreeFormat()
260 SDL_free(format); in SDL_FreeFormat()
296 pitch = surface->w*surface->format->BytesPerPixel; in SDL_CalculatePitch()
297 switch (surface->format->BitsPerPixel) { in SDL_CalculatePitch()
341 (const SDL_PixelFormat * const format, in SDL_MapRGB() argument
344 if ( format->palette == NULL ) { in SDL_MapRGB()
345 return (r >> format->Rloss) << format->Rshift in SDL_MapRGB()
346 | (g >> format->Gloss) << format->Gshift in SDL_MapRGB()
347 | (b >> format->Bloss) << format->Bshift in SDL_MapRGB()
348 | format->Amask; in SDL_MapRGB()
350 return SDL_FindColor(format->palette, r, g, b); in SDL_MapRGB()
356 (const SDL_PixelFormat * const format, in SDL_MapRGBA() argument
359 if ( format->palette == NULL ) { in SDL_MapRGBA()
360 return (r >> format->Rloss) << format->Rshift in SDL_MapRGBA()
361 | (g >> format->Gloss) << format->Gshift in SDL_MapRGBA()
362 | (b >> format->Bloss) << format->Bshift in SDL_MapRGBA()
363 | ((a >> format->Aloss) << format->Ashift & format->Amask); in SDL_MapRGBA()
365 return SDL_FindColor(format->palette, r, g, b); in SDL_MapRGBA()
557 srcfmt = src->format; in SDL_MapSurface()
558 dstfmt = dst->format; in SDL_MapSurface()