37 SDL_FreeSurface(this->surface);
90 SDL_RWops *ops = SDL_RWFromConstMem(bytes, (
int) length);
92 SDL_Surface *surface = IMG_LoadTyped_RW(ops, 0, self->
type);
95 SDL_FreeSurface(surface);
100 self = release(self);
116 self = release(self);
129 self->
type = strrchr(resource->name,
'.') ? strrchr(resource->name,
'.') + 1 : NULL;
132 self = release(self);
144 Resource *resource = $$(Resource, resourceWithName, name);
159 self = (
Image *) super(Object, self,
init);
163 if (surface->format->format != SDL_PIXELFORMAT_ABGR8888) {
164 self->
surface = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ABGR8888, 0);
185#pragma mark - Class lifecycle
192 ((ObjectInterface *) clazz->interface)->dealloc =
dealloc;
194 ((ImageInterface *) clazz->interface)->imageWithBytes =
imageWithBytes;
204 ((ImageInterface *) clazz->interface)->
size =
size;
216 clazz = _initialize(&(
const ClassDef) {
218 .superclass = _Object(),
219 .instanceSize =
sizeof(
Image),
220 .interfaceOffset = offsetof(
Image, interface),
221 .interfaceSize =
sizeof(ImageInterface),
static void dealloc(Object *self)
static void initialize(Class *clazz)
View logging facilities via SDL_Log.
#define MakeSize(w, h)
Creates an SDL_Size with the given dimensions.
CollectionView * init(CollectionView *self, const SDL_Rect *frame)
Initializes this CollectionView with the specified frame and style.
Font * initWithData(Font *self, Data *data, int size, int index)
Data * data
The raw font data.
SDL_Size size(const Image *self)
const char * type
The image type, inferred if instantiated with a Resource.
Image * initWithData(Image *self, const Data *data)
Initializes this Image with the specified Data.
Image * initWithResourceName(Image *self, const char *name)
Initializes this Image, loading the Resource by the given name.
Image * initWithBytes(Image *self, const uint8_t *bytes, size_t length)
Initializes this Image with the specified bytes.
Image * imageWithBytes(const uint8_t *bytes, size_t length)
Instantiates an Image with the specified bytes.
Class * _Image(void)
The Image archetype.
Image * imageWithResourceName(const char *name)
Instantiates an Image with the specified Resource name.
Image * imageWithData(const Data *data)
Instantiates an Image with the specified Data.
Image * initWithSurface(Image *self, SDL_Surface *surface)
Initializes this Image with the given surface.
SDL_Surface * surface
The backing surface.
Image * imageWithResource(const Resource *resource)
Instantiates an Image with the specified Resource.
Image * imageWithSurface(SDL_Surface *surface)
Instantiates an Image with the specified surface.
Image * initWithResource(Image *self, const Resource *resource)
Initializes this Image with the specified Resource.