Home | History | Annotate | Download | only in video

Lines Matching refs:format

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