note
	description: "Read-only version of a {GAME_PIXEL_FORMAT}."
	author: "Louis Marchand"
	date: "Thu, 02 Apr 2015 02:40:10 +0000"
	revision: "2.0"

class 
	GAME_PIXEL_FORMAT_READABLE

create {GAME_SDL_ANY}
	make_from_flags,
	make_from_structure_pointer,
	share_from_structure_pointer,
	own_from_structure_pointer,
	make_from_bits_per_pixel_and_masks


create 
	make_from_other

feature {NONE} -- Initialization

	default_create
			-- Process instances of classes with no creation clause.
			-- (Default: do nothing.)
			-- (from ANY)
		do
		end
	
feature -- Access

	bits_per_pixel: INTEGER_32
			-- The number of significant bits in a pixel value
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_bitsperpixel (internal_index)
		end

	bytes_per_pixel: INTEGER_32
			-- The number of bytes in a pixel value
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_bytesperpixel (internal_index)
		end

	color_palette: detachable GAME_COLOR_PALETTE
			-- The palette of color used in the indexed pixel format
		require
			is_indexed: is_indexed
		local
			l_palette: POINTER
		do
			Result := Void
			if not internal_item.is_default_pointer then
				l_palette := {GAME_SDL_EXTERNAL}.get_sdl_pixel_format_struct_palette (item)
				create Result.make_shared (l_palette)
			end
		end

	generating_type: TYPE [detachable GAME_PIXEL_FORMAT_READABLE]
			-- Type of current object
			-- (type of which it is a direct instance)
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			generating_type_not_void: Result /= Void
		end

	generator: STRING_8
			-- Name of current object's generating class
			-- (base class of the type of which it is a direct instance)
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			generator_not_void: Result /= Void
			generator_not_empty: not Result.is_empty
		end

	has_alpha: BOOLEAN
			-- Current used a color system with alpha channel
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_ispixelformat_indexed (internal_index)
		end

	has_error: BOOLEAN
			-- Is the library has generate an error
			-- (from GAME_ERROR_MANAGER)

	is_abgr1555: BOOLEAN
			-- the pixel format of Current is abgr1555
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_abgr1555
		end

	is_abgr4444: BOOLEAN
			-- the pixel format of Current is abgr4444
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_abgr4444
		end

	is_abgr8888: BOOLEAN
			-- the pixel format of Current is abgr8888
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_abgr8888
		end

	is_argb1555: BOOLEAN
			-- the pixel format of Current is argb1555
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_argb1555
		end

	is_argb2101010: BOOLEAN
			-- the pixel format of Current is argb2101010
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_argb2101010
		end

	is_argb4444: BOOLEAN
			-- the pixel format of Current is argb4444
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_argb4444
		end

	is_argb8888: BOOLEAN
			-- the pixel format of Current is argb8888
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_argb8888
		end

	is_bgr24: BOOLEAN
			-- the pixel format of Current is bgr24
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgr24
		end

	is_bgr555: BOOLEAN
			-- the pixel format of Current is bgr555
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgr555
		end

	is_bgr565: BOOLEAN
			-- the pixel format of Current is bgr565
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgr565
		end

	is_bgr888: BOOLEAN
			-- the pixel format of Current is bgr888
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgr888
		end

	is_bgra4444: BOOLEAN
			-- the pixel format of Current is bgra4444
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgra4444
		end

	is_bgra5551: BOOLEAN
			-- the pixel format of Current is bgra5551
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgra5551
		end

	is_bgra8888: BOOLEAN
			-- the pixel format of Current is bgra8888
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgra8888
		end

	is_bgrx8888: BOOLEAN
			-- the pixel format of Current is bgrx8888
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgrx8888
		end

	is_equal (a_other: like Current): BOOLEAN
			-- Is other attached to an object considered
			-- equal to current object?
		require -- from ANY
			other_not_void: a_other /= Void
		do
			Result := internal_index = a_other.internal_index
		ensure -- from ANY
			symmetric: Result implies a_other ~ Current
			consistent: standard_is_equal (a_other) implies Result
		end

	is_four_cc: BOOLEAN
			-- Current used a color system that represent a FourCC format (Like YUV)
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_ispixelformat_indexed (internal_index)
		end

	is_index1lsb: BOOLEAN
			-- the pixel format of Current is index1lsb
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_index1lsb
		end

	is_index1msb: BOOLEAN
			-- the pixel format of Current is index1msb
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_index1msb
		end

	is_index4lsb: BOOLEAN
			-- the pixel format of Current is index4lsb
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_index4lsb
		end

	is_index4msb: BOOLEAN
			-- the pixel format of Current is index4msb
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_index4msb
		end

	is_index8: BOOLEAN
			-- the pixel format of Current is index8
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_index8
		end

	is_indexed: BOOLEAN
			-- Current used an indexed color system
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_ispixelformat_indexed (internal_index)
		end

	is_iyuv: BOOLEAN
			-- the pixel format of Current is iyuv
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_iyuv
		end

	is_order_array_abgr: BOOLEAN
			-- The arrayed component order (low byte -> high byte) or Current is ABGR
		require
			is_arrayed: is_type_array_natural_8 or is_type_array_natural_16 or is_type_array_natural_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_arrayorder_abgr
		end

	is_order_array_argb: BOOLEAN
			-- The arrayed component order (low byte -> high byte) or Current is ARGB
		require
			is_arrayed: is_type_array_natural_8 or is_type_array_natural_16 or is_type_array_natural_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_arrayorder_argb
		end

	is_order_array_bgr: BOOLEAN
			-- The arrayed component order (low byte -> high byte) or Current is BGR
		require
			is_arrayed: is_type_array_natural_8 or is_type_array_natural_16 or is_type_array_natural_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_arrayorder_bgr
		end

	is_order_array_bgra: BOOLEAN
			-- The arrayed component order (low byte -> high byte) or Current is BGRA
		require
			is_arrayed: is_type_array_natural_8 or is_type_array_natural_16 or is_type_array_natural_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_arrayorder_bgra
		end

	is_order_array_rgb: BOOLEAN
			-- The arrayed component order (low byte -> high byte) or Current is RGB
		require
			is_arrayed: is_type_array_natural_8 or is_type_array_natural_16 or is_type_array_natural_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_arrayorder_rgb
		end

	is_order_array_rgba: BOOLEAN
			-- The arrayed component order (low byte -> high byte) or Current is RGBA
		require
			is_arrayed: is_type_array_natural_8 or is_type_array_natural_16 or is_type_array_natural_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_arrayorder_rgba
		end

	is_order_array_unknown: BOOLEAN
			-- The arrayed component order (low byte -> high byte) or Current is not known
		require
			is_arrayed: is_type_array_natural_8 or is_type_array_natural_16 or is_type_array_natural_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_arrayorder_none
		end

	is_order_bitmap_1234: BOOLEAN
			-- The bitmap pixel order (high bit -> low bit) or Current is 1234
		require
			is_bitmaped: is_type_index_1 or is_type_index_4
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_bitmaporder_1234
		end

	is_order_bitmap_4321: BOOLEAN
			-- The bitmap pixel order (high bit -> low bit) or Current is 4321
		require
			is_bitmaped: is_type_index_1 or is_type_index_4
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_bitmaporder_4321
		end

	is_order_bitmap_unknow: BOOLEAN
			-- The bitmap pixel order (high bit -> low bit) or Current is unknown
		require
			is_bitmaped: is_type_index_1 or is_type_index_4
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_bitmaporder_4321
		end

	is_order_packed_abgr: BOOLEAN
			-- The packed component order (high bit -> low bit) or Current is ABGR
		require
			is_packed: is_type_packed_8 or is_type_packed_16 or is_type_packed_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedorder_abgr
		end

	is_order_packed_argb: BOOLEAN
			-- The packed component order (high bit -> low bit) or Current is ARGB
		require
			is_packed: is_type_packed_8 or is_type_packed_16 or is_type_packed_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedorder_argb
		end

	is_order_packed_bgra: BOOLEAN
			-- The packed component order (high bit -> low bit) or Current is BGRA
		require
			is_packed: is_type_packed_8 or is_type_packed_16 or is_type_packed_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedorder_bgra
		end

	is_order_packed_bgrx: BOOLEAN
			-- The packed component order (high bit -> low bit) or Current is BGRX
		require
			is_packed: is_type_packed_8 or is_type_packed_16 or is_type_packed_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedorder_bgrx
		end

	is_order_packed_rgba: BOOLEAN
			-- The packed component order (high bit -> low bit) or Current is RGBA
		require
			is_packed: is_type_packed_8 or is_type_packed_16 or is_type_packed_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedorder_rgba
		end

	is_order_packed_rgbx: BOOLEAN
			-- The packed component order (high bit -> low bit) or Current is RGBX
		require
			is_packed: is_type_packed_8 or is_type_packed_16 or is_type_packed_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedorder_rgbx
		end

	is_order_packed_unknown: BOOLEAN
			-- The packed component order (high bit -> low bit) or Current is not known
		require
			is_packed: is_type_packed_8 or is_type_packed_16 or is_type_packed_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedorder_none
		end

	is_order_packed_xbgr: BOOLEAN
			-- The packed component order (high bit -> low bit) or Current is XBGR
		require
			is_packed: is_type_packed_8 or is_type_packed_16 or is_type_packed_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedorder_xbgr
		end

	is_order_packed_xrgb: BOOLEAN
			-- The packed component order (high bit -> low bit) or Current is XRGB
		require
			is_packed: is_type_packed_8 or is_type_packed_16 or is_type_packed_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixelorder (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedorder_xrgb
		end

	is_packed_layout_1010102: BOOLEAN
			-- Current have the channel layouts 1010102
		require
			is_packed: is_type_packed_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixellayout (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedlayout_1010102
		end

	is_packed_layout_1555: BOOLEAN
			-- Current have the channel layouts 1555
		require
			is_packed: is_type_packed_16
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixellayout (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedlayout_1555
		end

	is_packed_layout_2101010: BOOLEAN
			-- Current have the channel layouts 2101010
		require
			is_packed: is_type_packed_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixellayout (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedlayout_2101010
		end

	is_packed_layout_332: BOOLEAN
			-- Current have the channel layouts 332
		require
			is_packed: is_type_packed_8
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixellayout (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedlayout_332
		end

	is_packed_layout_4444: BOOLEAN
			-- Current have the channel layouts 4444
		require
			is_packed: is_type_packed_16
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixellayout (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedlayout_4444
		end

	is_packed_layout_5551: BOOLEAN
			-- Current have the channel layouts 5551
		require
			is_packed: is_type_packed_16
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixellayout (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedlayout_5551
		end

	is_packed_layout_565: BOOLEAN
			-- Current have the channel layouts 565
		require
			is_packed: is_type_packed_16
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixellayout (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedlayout_565
		end

	is_packed_layout_8888: BOOLEAN
			-- Current have the channel layouts 8888
		require
			is_packed: is_type_packed_32
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixellayout (internal_index) = {GAME_SDL_EXTERNAL}.sdl_packedlayout_8888
		end

	is_rgb24: BOOLEAN
			-- the pixel format of Current is rgb24
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgb24
		end

	is_rgb332: BOOLEAN
			-- the pixel format of Current is rgb332
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgb332
		end

	is_rgb444: BOOLEAN
			-- the pixel format of Current is rgb444
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgb444
		end

	is_rgb555: BOOLEAN
			-- the pixel format of Current is rgb555
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgb555
		end

	is_rgb565: BOOLEAN
			-- the pixel format of Current is rgb565
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgb565
		end

	is_rgb888: BOOLEAN
			-- the pixel format of Current is rgb888
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgb888
		end

	is_rgba4444: BOOLEAN
			-- the pixel format of Current is rgba4444
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgba4444
		end

	is_rgba5551: BOOLEAN
			-- the pixel format of Current is rgba5551
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgba5551
		end

	is_rgba8888: BOOLEAN
			-- the pixel format of Current is rgba8888
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgba8888
		end

	is_rgbx8888: BOOLEAN
			-- the pixel format of Current is rgbx8888
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgbx8888
		end

	is_type_array_natural_16: BOOLEAN
			-- the pixel format of Current is of type array of 16 bits natural number (ARRAYU16)
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixeltype (internal_index) = {GAME_SDL_EXTERNAL}.sdl_pixeltype_arrayu16
		end

	is_type_array_natural_32: BOOLEAN
			-- the pixel format of Current is of type array of 32 bits natural number (ARRAYU16)
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixeltype (internal_index) = {GAME_SDL_EXTERNAL}.sdl_pixeltype_arrayu32
		end

	is_type_array_natural_8: BOOLEAN
			-- the pixel format of Current is of type array of 8 bits natural number (ARRAYU8)
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixeltype (internal_index) = {GAME_SDL_EXTERNAL}.sdl_pixeltype_arrayu8
		end

	is_type_index_1: BOOLEAN
			-- the pixel format of Current is of type index 1 bit
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixeltype (internal_index) = {GAME_SDL_EXTERNAL}.sdl_pixeltype_index1
		end

	is_type_index_4: BOOLEAN
			-- the pixel format of Current is of type index 4 bits
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixeltype (internal_index) = {GAME_SDL_EXTERNAL}.sdl_pixeltype_index4
		end

	is_type_index_8: BOOLEAN
			-- the pixel format of Current is of type index 8 bits
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixeltype (internal_index) = {GAME_SDL_EXTERNAL}.sdl_pixeltype_index8
		end

	is_type_packed_16: BOOLEAN
			-- the pixel format of Current is of type packed 16 bits
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixeltype (internal_index) = {GAME_SDL_EXTERNAL}.sdl_pixeltype_packed16
		end

	is_type_packed_32: BOOLEAN
			-- the pixel format of Current is of type packed 32 bits
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixeltype (internal_index) = {GAME_SDL_EXTERNAL}.sdl_pixeltype_packed32
		end

	is_type_packed_8: BOOLEAN
			-- the pixel format of Current is of type packed 8 bits
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixeltype (internal_index) = {GAME_SDL_EXTERNAL}.sdl_pixeltype_packed8
		end

	is_type_unknown: BOOLEAN
			-- the pixel format of Current is not of a known type
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_pixeltype (internal_index) = {GAME_SDL_EXTERNAL}.sdl_pixeltype_unknown
		end

	is_unknown: BOOLEAN
			-- the pixel format of Current is unknown
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_unknown
		end

	is_unsuported: BOOLEAN
			-- the pixel format of Current is not currently supported
		do
			Result := not is_internal_index_supported (internal_index)
		end

	is_uyvy: BOOLEAN
			-- the pixel format of Current is uyvy
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_uyvy
		end

	is_yuy2: BOOLEAN
			-- the pixel format of Current is yuy2
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_yuy2
		end

	is_yv12: BOOLEAN
			-- the pixel format of Current is yv12
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_yv12
		end

	is_yvyu: BOOLEAN
			-- the pixel format of Current is yvyu
		do
			Result := internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_yvyu
		end

	last_error: READABLE_STRING_GENERAL
			-- The last error generate by the library
			-- (from GAME_SDL_ANY)
		local
			l_string: C_STRING
		do
			if is_manual_error then
				Result := Precursor {GAME_ERROR_MANAGER}
			else
				create l_string.make_by_pointer ({GAME_SDL_EXTERNAL}.sdl_geterror)
				Result := l_string.string
			end
		end

	masks: TUPLE [red_mask: NATURAL_32; green_mask: NATURAL_32; blue_mask: NATURAL_32; alpha_mask: NATURAL_32]
			-- Masks representing the location of the red, green, blue and alpha components of the pixel
		local
			l_structure: POINTER
			l_dummy: NATURAL_32
		do
			l_structure := item
			if l_structure.is_default_pointer then
				l_dummy := 0
				Result := [l_dummy, l_dummy, l_dummy, l_dummy]
			else
				Result := [{GAME_SDL_EXTERNAL}.get_sdl_pixel_format_struct_rmask (l_structure), {GAME_SDL_EXTERNAL}.get_sdl_pixel_format_struct_gmask (l_structure), {GAME_SDL_EXTERNAL}.get_sdl_pixel_format_struct_bmask (l_structure), {GAME_SDL_EXTERNAL}.get_sdl_pixel_format_struct_amask (l_structure)]
			end
		end

	out: STRING_8
			-- A text representation of the pixel format of Current.
		do
			if is_unknown then
				Result := "unknown"
			elseif is_index1lsb then
				Result := "index1lsb"
			elseif is_index1msb then
				Result := "index1msb"
			elseif is_index4lsb then
				Result := "index4lsb"
			elseif is_index4msb then
				Result := "index4msb"
			elseif is_index8 then
				Result := "index8"
			elseif is_rgb332 then
				Result := "rgb332"
			elseif is_rgb444 then
				Result := "rgb444"
			elseif is_rgb555 then
				Result := "rgb555"
			elseif is_bgr555 then
				Result := "bgr555"
			elseif is_argb4444 then
				Result := "argb4444"
			elseif is_rgba4444 then
				Result := "rgba4444"
			elseif is_abgr4444 then
				Result := "abgr4444"
			elseif is_bgra4444 then
				Result := "bgra4444"
			elseif is_argb1555 then
				Result := "argb1555"
			elseif is_rgba5551 then
				Result := "rgba5551"
			elseif is_abgr1555 then
				Result := "abgr1555"
			elseif is_bgra5551 then
				Result := "bgra5551"
			elseif is_rgb565 then
				Result := "rgb565"
			elseif is_bgr565 then
				Result := "bgr565"
			elseif is_rgb24 then
				Result := "rgb24"
			elseif is_bgr24 then
				Result := "bgr24"
			elseif is_rgb888 then
				Result := "rgb888"
			elseif is_rgbx8888 then
				Result := "rgbx8888"
			elseif is_bgr888 then
				Result := "bgr888"
			elseif is_bgrx8888 then
				Result := "bgrx8888"
			elseif is_argb8888 then
				Result := "argb8888"
			elseif is_rgba8888 then
				Result := "rgba8888"
			elseif is_abgr8888 then
				Result := "abgr8888"
			elseif is_bgra8888 then
				Result := "bgra8888"
			elseif is_argb2101010 then
				Result := "argb2101010"
			elseif is_yv12 then
				Result := "yv12"
			elseif is_iyuv then
				Result := "iyuv"
			elseif is_yuy2 then
				Result := "yuy2"
			elseif is_uyvy then
				Result := "uyvy"
			elseif is_yvyu then
				Result := "yvyu"
			else
				Result := "Unsuported"
			end
		ensure -- from ANY
			out_not_void: Result /= Void
		end
	
feature -- Comparison

	frozen deep_equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void
			-- or attached to isomorphic object structures?
			-- (from ANY)
		do
			if a = Void then
				Result := b = Void
			else
				Result := b /= Void and then a.is_deep_equal (b)
			end
		ensure -- from ANY
			instance_free: class
			shallow_implies_deep: standard_equal (a, b) implies Result
			both_or_none_void: (a = Void) implies (Result = (b = Void))
			same_type: (Result and (a /= Void)) implies (b /= Void and then a.same_type (b))
			symmetric: Result implies deep_equal (b, a)
		end

	frozen equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void or attached
			-- to objects considered equal?
			-- (from ANY)
		do
			if a = Void then
				Result := b = Void
			else
				Result := b /= Void and then a.is_equal (b)
			end
		ensure -- from ANY
			instance_free: class
			definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.is_equal (b))
		end

	frozen is_deep_equal alias "≡≡≡" (other: GAME_PIXEL_FORMAT_READABLE): BOOLEAN
			-- Are Current and other attached to isomorphic object structures?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		ensure -- from ANY
			shallow_implies_deep: standard_is_equal (other) implies Result
			same_type: Result implies same_type (other)
			symmetric: Result implies other.is_deep_equal (Current)
		end

	frozen standard_equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void or attached to
			-- field-by-field identical objects of the same type?
			-- Always uses default object comparison criterion.
			-- (from ANY)
		do
			if a = Void then
				Result := b = Void
			else
				Result := b /= Void and then a.standard_is_equal (b)
			end
		ensure -- from ANY
			instance_free: class
			definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.standard_is_equal (b))
		end

	frozen standard_is_equal alias "≜" (other: GAME_PIXEL_FORMAT_READABLE): BOOLEAN
			-- Is other attached to an object of the same type
			-- as current object, and field-by-field identical to it?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		ensure -- from ANY
			same_type: Result implies same_type (other)
			symmetric: Result implies other.standard_is_equal (Current)
		end
	
feature {NONE} -- Status report

	is_in_final_collect: BOOLEAN
			-- Is GC currently performing final collection
			-- after execution of current program?
			-- Safe to use in dispose.
			-- (from DISPOSABLE)
		external
			"C inline use %"eif_memory.h%""
		alias
			"return eif_is_in_final_collect;"
		end
	
feature -- Status report

	conforms_to (other: ANY): BOOLEAN
			-- Does type of current object conform to type
			-- of other (as per Eiffel: The Language, chapter 13)?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		end

	same_type (other: ANY): BOOLEAN
			-- Is type of current object identical to type of other?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		ensure -- from ANY
			definition: Result = (conforms_to (other) and other.conforms_to (Current))
		end
	
feature -- Duplication

	frozen clone (other: detachable ANY): like other
		obsolete "Use `twin' instead. [2017-05-31]"
			-- Void if other is void; otherwise new object
			-- equal to other
			--
			-- For non-void other, clone calls copy;
			-- to change copying/cloning semantics, redefine copy.
			-- (from ANY)
		do
			if other /= Void then
				Result := other.twin
			end
		ensure -- from ANY
			instance_free: class
			equal: Result ~ other
		end

	copy (other: GAME_PIXEL_FORMAT_READABLE)
			-- Update current object using fields of object attached
			-- to other, so as to yield equal objects.
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		external
			"built_in"
		ensure -- from ANY
			is_equal: Current ~ other
		end

	frozen deep_clone (other: detachable ANY): like other
		obsolete "Use `deep_twin' instead. [2017-05-31]"
			-- Void if other is void: otherwise, new object structure
			-- recursively duplicated from the one attached to other
			-- (from ANY)
		do
			if other /= Void then
				Result := other.deep_twin
			end
		ensure -- from ANY
			instance_free: class
			deep_equal: deep_equal (other, Result)
		end

	frozen deep_copy (other: GAME_PIXEL_FORMAT_READABLE)
			-- Effect equivalent to that of:
			--		copy (other . deep_twin)
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		do
			copy (other.deep_twin)
		ensure -- from ANY
			deep_equal: deep_equal (Current, other)
		end

	frozen deep_twin: GAME_PIXEL_FORMAT_READABLE
			-- New object structure recursively duplicated from Current.
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			deep_twin_not_void: Result /= Void
			deep_equal: deep_equal (Current, Result)
		end

	frozen standard_clone (other: detachable ANY): like other
		obsolete "Use `standard_twin' instead. [2017-05-31]"
			-- Void if other is void; otherwise new object
			-- field-by-field identical to other.
			-- Always uses default copying semantics.
			-- (from ANY)
		do
			if other /= Void then
				Result := other.standard_twin
			end
		ensure -- from ANY
			instance_free: class
			equal: standard_equal (Result, other)
		end

	frozen standard_copy (other: GAME_PIXEL_FORMAT_READABLE)
			-- Copy every field of other onto corresponding field
			-- of current object.
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		external
			"built_in"
		ensure -- from ANY
			is_standard_equal: standard_is_equal (other)
		end

	frozen standard_twin: GAME_PIXEL_FORMAT_READABLE
			-- New object field-by-field identical to other.
			-- Always uses default copying semantics.
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			standard_twin_not_void: Result /= Void
			equal: standard_equal (Result, Current)
		end

	frozen twin: GAME_PIXEL_FORMAT_READABLE
			-- New object equal to Current
			-- twin calls copy; to change copying/twinning semantics, redefine copy.
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			twin_not_void: Result /= Void
			is_equal: Result ~ Current
		end
	
feature -- Basic operations

	frozen as_attached: attached GAME_PIXEL_FORMAT_READABLE
		obsolete "Remove calls to this feature. [2017-05-31]"
			-- Attached version of Current.
			-- (Can be used during transitional period to convert
			-- non-void-safe classes to void-safe ones.)
			-- (from ANY)
		do
			Result := Current
		end

	frozen default: detachable GAME_PIXEL_FORMAT_READABLE
			-- Default value of object's type
			-- (from ANY)
		do
		end

	frozen default_pointer: POINTER
			-- Default value of type POINTER
			-- (Avoid the need to write p.default for
			-- some p of type POINTER.)
			-- (from ANY)
		do
		ensure -- from ANY
			instance_free: class
		end

	default_rescue
			-- Process exception for routines with no Rescue clause.
			-- (Default: do nothing.)
			-- (from ANY)
		do
		end

	frozen do_nothing
			-- Execute a null action.
			-- (from ANY)
		do
		ensure -- from ANY
			instance_free: class
		end
	
feature {GAME_SDL_ANY} -- Implementation

	internal_index: NATURAL_32
			-- The internal C flags representing Current.

	item: POINTER
			-- A C structure pointer that is representing Current
		do
			if internal_item.is_default_pointer then
				clear_error
				internal_item := {GAME_SDL_EXTERNAL}.sdl_allocformat (internal_index)
				manage_error_pointer (internal_item, "An error occured while getting the structure of a Pixel Format.")
				must_free_structure := True
			end
			Result := internal_item
		end
	
feature {NONE} -- Implementation

	clear_error
			-- Remove error pending in Current
			-- (from GAME_SDL_ANY)
		require -- from  GAME_ERROR_MANAGER
			True
		do
			{GAME_SDL_EXTERNAL}.sdl_clearerror
			Precursor {GAME_ERROR_MANAGER}
			is_manual_error := False
		ensure -- from GAME_ERROR_MANAGER
			no_error: not has_error
		ensure then -- from GAME_SDL_ANY
			no_error: not is_manual_error
		end

	disable_print_on_error
			-- Desactive the print_on_error functionnality.
			-- (from GAME_ERROR_MANAGER)
		do
			Print_on_error_internal.put (False)
		end

	enable_print_on_error
			-- Active the print_on_error functionnality.
			-- (from GAME_ERROR_MANAGER)
		do
			Print_on_error_internal.put (True)
		end

	internal_item: POINTER
			-- The internal value of the lazy evaluated item attribute

	is_internal_index_supported (a_internal_index: NATURAL_32): BOOLEAN
			-- Is a_internal_index a valid pixel format C internal_index.
		do
			Result := a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_unknown or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_index1lsb or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_index1msb or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_index4lsb or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_index4msb or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_index8 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgb332 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgb444 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgb555 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgr555 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_argb4444 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgba4444 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_abgr4444 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgra4444 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_argb1555 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgba5551 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_abgr1555 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgra5551 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgb565 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgr565 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgb24 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgr24 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgb888 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgbx8888 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgr888 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgrx8888 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_argb8888 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_rgba8888 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_abgr8888 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_bgra8888 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_argb2101010 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_yv12 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_iyuv or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_yuy2 or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_uyvy or a_internal_index = {GAME_SDL_EXTERNAL}.sdl_pixelformat_yvyu
		end

	is_manual_error: BOOLEAN
			-- Is the current pending error is a manual error (using manual_error as message)
			-- (from GAME_SDL_ANY)

	manage_error_boolean (a_boolean: BOOLEAN; a_message: READABLE_STRING_GENERAL)
			-- Create an error if a_boolean is false.
			-- If there is an error, append a_message to the error message
			-- on the SDL2 library
			-- (from GAME_SDL_ANY)
		do
			if not a_boolean then
				if Print_on_error_internal.item then
					Io.Error.put_string (a_message.to_string_8 + "%N");
					Io.Error.put_string (last_error.to_string_8 + "%N")
				end
				has_error := True
			end
		ensure -- from GAME_SDL_ANY
				not a_boolean implies has_error
		end

	manage_error_code (a_error_code: INTEGER_32; a_message: READABLE_STRING_GENERAL)
			-- If needed create an error depending of the error code a_code.
			-- If there is an error, append a_message to the error message
			-- on the SDL2 library
			-- (from GAME_SDL_ANY)
		do
			if a_error_code < 0 then
				if Print_on_error_internal.item then
					Io.Error.put_string (a_message.to_string_8 + "%N");
					Io.Error.put_string (last_error.to_string_8 + "%N")
				end
				has_error := True
			end
		end

	manage_error_pointer (a_pointer: POINTER; a_message: READABLE_STRING_GENERAL)
			-- Create an error if a_pointer is not valid.
			-- If there is an error, append a_message to the error message
			-- on the SDL2 library
			-- (from GAME_SDL_ANY)
		do
			if a_pointer.is_default_pointer then
				if Print_on_error_internal.item then
					Io.Error.put_string (a_message.to_string_8 + "%N");
					Io.Error.put_string (last_error.to_string_8 + "%N")
				end
				has_error := True
			end
		ensure -- from GAME_SDL_ANY
				a_pointer.is_default_pointer implies has_error
		end

	manual_error: detachable READABLE_STRING_GENERAL
			-- The specific message for the last error
			-- (from GAME_ERROR_MANAGER)

	must_free_structure: BOOLEAN
			-- Is the responsability or Current to free item

	print_on_error: BOOLEAN
			-- When an error occured, the library will print
			-- informations about the error on the error console
			-- output (default is True).
			-- (from GAME_ERROR_MANAGER)
		do
			Result := Print_on_error_internal.item
		end

	Print_on_error_internal: CELL [BOOLEAN]
			-- True when an error occured,
			-- The library will print it right away.
			-- (from GAME_ERROR_MANAGER)
		once ("PROCESS")
			create Result.put (True)
		end

	put_manual_error (a_general_message, a_specific_error: READABLE_STRING_GENERAL)
			-- Create an error using a_general_error for the debug information
			-- and a_specific_error for the lasting information
			-- (from GAME_SDL_ANY)
		do
			is_manual_error := True
			Precursor {GAME_ERROR_MANAGER} (a_general_message, a_specific_error)
		ensure -- from GAME_ERROR_MANAGER
				has_error
		end

	set_color_palette (a_color_palette: detachable GAME_COLOR_PALETTE)
			-- Assign the color_palette with the value of a_color_palette
		require
			is_indexed: is_indexed
			has_valid_color_number: attached a_color_palette implies a_color_palette.count = (1).bit_shift_left (bits_per_pixel)
		local
			l_error: INTEGER_32
		do
			if attached a_color_palette then
				l_error := {GAME_SDL_EXTERNAL}.sdl_setpixelformatpalette (item, a_color_palette.internal_pointer)
			else
				l_error := {GAME_SDL_EXTERNAL}.sdl_setpixelformatpalette (item, create {POINTER})
			end
			manage_error_code (l_error, "Cannot assign color palette.")
		ensure
			is_set: not has_error implies color_palette ~ a_color_palette
		end

	set_internal_index (a_internal_index: NATURAL_32)
			-- Assign the internal C internal_index representing Current.
		do
			if a_internal_index /= internal_index then
				internal_index := a_internal_index
				dispose
			end
		ensure
			pixel_format_flags_changed: internal_index = a_internal_index
		end

	set_print_on_error (a_value: BOOLEAN)
			-- Assign to print_on_error the value of a_value
			-- (from GAME_ERROR_MANAGER)
		do
			if a_value then
				enable_print_on_error
			else
				disable_print_on_error
			end
		ensure -- from GAME_ERROR_MANAGER
			is_assign: print_on_error ~ a_value
		end
	
feature -- Implementation

	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 internal_item.is_default_pointer then
				if must_free_structure then
					{GAME_SDL_EXTERNAL}.sdl_freeformat (internal_item)
				end
				internal_item := create {POINTER}
			end
		end
	
feature {NONE} -- Initialisation

	make_from_bits_per_pixel_and_masks (a_bits_per_pixel: INTEGER_32; a_red_mask, a_green_mask, a_blue_mask, a_alpha_mask: NATURAL_32)
			-- Initialize Current usign a_bits_per_pixel value and pixel masks: a_red_mask, a_green_mask, a_blue_mask and a_alpha_mask.
		do
			make_from_flags ({GAME_SDL_EXTERNAL}.sdl_maskstopixelformatenum (a_bits_per_pixel, a_red_mask, a_green_mask, a_blue_mask, a_alpha_mask))
		end

	make_from_flags (a_enum: NATURAL_32)
			-- Initialization for Current usign the internal format index.
		do
			set_internal_index (a_enum)
		end

	make_from_other (a_other: GAME_PIXEL_FORMAT_READABLE)
			-- Initialization for Current by copying a_others values.
		do
			make_from_flags (a_other.internal_index)
			set_color_palette (a_other.color_palette)
		end

	make_from_structure_pointer (a_structure: POINTER)
			-- Initialize usign the copy of a_structure format C pointer.
			-- a_structure is not freed by Current
		require
			pixel_format_info_structure_not_null: not a_structure.is_default_pointer
		local
			l_temp_palette: detachable GAME_COLOR_PALETTE
		do
			share_from_structure_pointer (a_structure)
			l_temp_palette := color_palette
			internal_item := create {POINTER}
			if attached l_temp_palette then
				set_color_palette (l_temp_palette)
			end
		end

	own_from_structure_pointer (a_structure: POINTER)
			-- Initialize usign a_structure format C pointer.
			-- a_structure will be freed by Current
		require
			pixel_format_info_structure_not_null: not a_structure.is_default_pointer
		do
			share_from_structure_pointer (a_structure)
			must_free_structure := True
		end

	share_from_structure_pointer (a_structure: POINTER)
			-- Initialize usign a_structure format C pointer.
			-- a_structure is not freed by Current
		require
			pixel_format_info_structure_not_null: not a_structure.is_default_pointer
		do
			make_from_flags ({GAME_SDL_EXTERNAL}.get_sdl_pixel_format_struct_format (a_structure))
			internal_item := a_structure
			must_free_structure := False
		end
	
feature -- Output

	Io: STD_FILES
			-- Handle to standard file setup
			-- (from ANY)
		once
			create Result;
			Result.set_output_default
		ensure -- from ANY
			instance_free: class
			io_not_void: Result /= Void
		end

	print (o: detachable ANY)
			-- Write terse external representation of o
			-- on standard output.
			-- (from ANY)
		local
			s: READABLE_STRING_8
		do
			if attached o then
				s := o.out
				if attached {READABLE_STRING_32} s as s32 then
					Io.put_string_32 (s32)
				elseif attached {READABLE_STRING_8} s as s8 then
					Io.put_string (s8)
				else
					Io.put_string_32 (s.as_string_32)
				end
			end
		ensure -- from ANY
			instance_free: class
		end

	frozen tagged_out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			tagged_out_not_void: Result /= Void
		end
	
feature -- Platform

	Operating_environment: OPERATING_ENVIRONMENT
			-- Objects available from the operating system
			-- (from ANY)
		once
			create Result
		ensure -- from ANY
			instance_free: class
			operating_environment_not_void: Result /= Void
		end
	
feature {NONE} -- Retrieval

	frozen internal_correct_mismatch
			-- Called from runtime to perform a proper dynamic dispatch on correct_mismatch
			-- from MISMATCH_CORRECTOR.
			-- (from ANY)
		local
			l_msg: STRING_32
			l_exc: EXCEPTIONS
		do
			if attached {MISMATCH_CORRECTOR} Current as l_corrector then
				l_corrector.correct_mismatch
			else
				create l_msg.make_from_string ("Mismatch: ".as_string_32)
				create l_exc;
				l_msg.append (generating_type.name_32);
				l_exc.raise_retrieval_exception (l_msg)
			end
		end
	
invariant
		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

end -- class GAME_PIXEL_FORMAT_READABLE

Generated by ISE EiffelStudio