note description: "An image from an image file" author: "Louis Marchand" date: "Thu, 02 Apr 2015 03:46:04 +0000" revision: "2.0" class IMG_IMAGE_FILE inherit GAME_IMAGE rename clear_error as clear_sdl_error, last_error as last_sdl_error redefine is_openable, open, dispose end IMG_ANY undefine default_create select clear_error, last_error end create make feature {NONE} -- Implementation make (a_filename: READABLE_STRING_GENERAL) -- make Current from the BMP image file filename. local l_filename_c, l_mode_c: C_STRING do default_create create l_filename_c.make (a_filename) create l_mode_c.make ("rb") rwop := {GAME_SDL_EXTERNAL}.sdl_rwfromfile (l_filename_c.item, l_mode_c.item) end feature -- Access is_cur: BOOLEAN -- The internal library support BMP format and the file is a valid CUR file. do Result := ({IMG_SDL_IMAGE_EXTERNAL}.img_iscur (rwop) = 1) end is_ico: BOOLEAN -- The internal library support BMP format and the file is a valid ICO file. do Result := ({IMG_SDL_IMAGE_EXTERNAL}.img_isico (rwop) = 1) end is_bmp: BOOLEAN -- The internal library support BMP format and the file is a valid BMP file. do Result := ({IMG_SDL_IMAGE_EXTERNAL}.img_isbmp (rwop) = 1) end is_pnm: BOOLEAN -- The internal library support PNM format and the file is a valid PNM file. do Result := ({IMG_SDL_IMAGE_EXTERNAL}.img_ispnm (rwop) = 1) end is_xpm: BOOLEAN -- The internal library support XPM format and the file is a valid XPM file. do Result := ({IMG_SDL_IMAGE_EXTERNAL}.img_isxpm (rwop) = 1) end is_xcf: BOOLEAN -- The internal library support XCF format and the file is a valid XCF file. do Result := ({IMG_SDL_IMAGE_EXTERNAL}.img_isxcf (rwop) = 1) end is_pcx: BOOLEAN -- The internal library support PCX format and the file is a valid PCX file. do Result := ({IMG_SDL_IMAGE_EXTERNAL}.img_ispcx (rwop) = 1) end is_gif: BOOLEAN -- The internal library support GIF format and the file is a valid GIF file. do Result := ({IMG_SDL_IMAGE_EXTERNAL}.img_isgif (rwop) = 1) end is_jpg: BOOLEAN -- The internal library support JPG format and the file is a valid JPG file. do Result := ({IMG_SDL_IMAGE_EXTERNAL}.img_isjpg (rwop) = 1) Result := True end is_tif: BOOLEAN -- The internal library support TIF format and the file is a valid TIF file. do Result := ({IMG_SDL_IMAGE_EXTERNAL}.img_istif (rwop) = 1) end is_png: BOOLEAN -- The internal library support PNG format and the file is a valid PNG file. do Result := ({IMG_SDL_IMAGE_EXTERNAL}.img_ispng (rwop) = 1) end is_lbm: BOOLEAN -- The internal library support LBM format and the file is a valid LBM file. do Result := ({IMG_SDL_IMAGE_EXTERNAL}.img_islbm (rwop) = 1) end is_xv: BOOLEAN -- The internal library support XV format and the file is a valid XV file. do Result := ({IMG_SDL_IMAGE_EXTERNAL}.img_isxv (rwop) = 1) end is_openable: BOOLEAN -- Can Current be open do Result := (not rwop.is_default_pointer) and then (is_cur or is_ico or is_bmp or is_pnm or is_xpm or is_xcf or is_pcx or is_gif or is_jpg or is_tif or is_png or is_lbm or is_xv) end open -- Open Current local l_internal_pointer: POINTER do clear_error l_internal_pointer := {IMG_SDL_IMAGE_EXTERNAL}.img_load_rw (rwop, 0) if l_internal_pointer.is_default_pointer then Io.Error.put_string ("An error occured while opening the image.%N"); Io.Error.put_string (last_error.to_string_8 + "%N") has_error := True end own_from_pointer (l_internal_pointer) has_ressource_error := has_error is_open := not has_error end feature {NONE} -- Implementation - Variable rwop: POINTER -- Pointer to the Read/Write C tool dispose -- Action to be executed just before garbage collection -- reclaims an object. -- Effect it in descendants to perform specific dispose -- actions. Those actions should only take care of freeing -- external resources; they should not perform remote calls -- on other objects since these may also be dead and reclaimed. do if not rwop.is_default_pointer then {GAME_SDL_EXTERNAL}.sdl_freerw (rwop) end Precursor {GAME_IMAGE} end end -- class IMG_IMAGE_FILE
Generated by ISE EiffelStudio