app::text::text(int w, int h) : data(0), x(0), y(0), inner_w(w), inner_h(h), outer_w(0), outer_h(0) { outer_w = int(topow2((unsigned int) inner_w)); outer_h = int(topow2((unsigned int) inner_h)); if (outer_w && outer_h) data = ::glob->new_image(outer_w, outer_h); }
void arrayresize(Array *array, size_t nmemb) { size_t nalloc = topow2(nmemb); if(nmemb < array->nmemb && array->nalloc > nalloc * 2) nalloc *= 2; array->ptr = realloc(array->ptr, nalloc * array->size); array->nalloc = nalloc; array->nmemb = nmemb; }
SDL_Surface* pow2img(SDL_Surface *src) { if(ISPOW2(src->w) && ISPOW2(src->h)) return src; SDL_SetAlpha(src, 0, SDL_ALPHA_OPAQUE); SDL_Surface *dst = NULL; dst = SDL_CreateRGBSurface(src->flags, topow2(src->w), topow2(src->h), src->format->BitsPerPixel, src->format->Rmask, src->format->Gmask, src->format->Bmask, src->format->Amask); if(!dst || SDL_BlitSurface(src, NULL, dst, NULL)) { SDL_FreeSurface(dst); return NULL; } return dst; }