Class: SDL2::PixelFormat
- Inherits:
-
Object
- Object
- SDL2::PixelFormat
- Defined in:
- video.c,
video.c
Overview
This class represents pixel format of textures, windows, and displays.
In C level, SDL use unsigned integers as pixel formats. This class wraps these integers. You can get the integers from #format.
Defined Under Namespace
Modules: ArrayOrder, BitmapOrder, PackedLayout, PackedOrder, Type
Constant Summary
- FORMATS =
Array of all available formats
-
- UNKNOWN =
PixelFormat: Unused - reserved by SDL
-
- INDEX1LSB =
format
- INDEX1MSB =
format
- INDEX4LSB =
format
- INDEX4MSB =
format
- INDEX8 =
format
- RGB332 =
format
- RGB444 =
format
- RGB555 =
format
- BGR555 =
format
- ARGB4444 =
format
- RGBA4444 =
format
- ABGR4444 =
format
- BGRA4444 =
format
- ARGB1555 =
format
- RGBA5551 =
format
- ABGR1555 =
format
- BGRA5551 =
format
- RGB565 =
format
- BGR565 =
format
- RGB24 =
format
- BGR24 =
format
- RGB888 =
format
- RGBX8888 =
format
- BGR888 =
format
- BGRX8888 =
format
- ARGB8888 =
format
- RGBA8888 =
format
- ABGR8888 =
format
- BGRA8888 =
format
- ARGB2101010 =
format
- YV12 =
format
- IYUV =
format
- YUY2 =
format
- UYVY =
format
- YVYU =
format
Instance Attribute Summary collapse
-
#format ⇒ Integer
readonly
An integer representing the pixel format.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Return true if two pixel format is the same format.
-
#alpha? ⇒ Boolean
Return true if the pixel format have an alpha channel.
-
#bits_per_pixel ⇒ Integer
(also: #bpp)
Get the number of bits per pixel.
-
#bytes_per_pixel ⇒ Integer
Get the number of bytes per pixel.
-
#fourcc? ⇒ Boolean
Return true if the pixel format is not indexed, and not RGB(A), for example, the pixel format is YUV.
-
#indexed? ⇒ Boolean
Return true if the pixel format have a palette.
-
#initialze(format) ⇒ Object
constructor
Initialize pixel format from the given integer representing a fomrmat.
-
#inspect ⇒ String
Inspection string.
-
#layout ⇒ Integer
Get the channel bit pattern of the pixel format.
-
#name ⇒ String
Get the human readable name of the pixel format.
-
#order ⇒ Integer
Get the ordering of channels or bits in the pixel format.
-
#type ⇒ Integer
Get the type of the format.
Constructor Details
#initialze(format) ⇒ Object
2650 2651 2652 2653 2654 |
# File 'video.c', line 2650
static VALUE PixelForamt_initialize(VALUE self, VALUE format)
{
rb_iv_set(self, "@format", format);
return Qnil;
}
|
Instance Attribute Details
#format ⇒ Integer (readonly)
An integer representing the pixel format.
Instance Method Details
#==(other) ⇒ Boolean
2751 2752 2753 2754 2755 2756 2757 |
# File 'video.c', line 2751
static VALUE PixelFormat_eq(VALUE self, VALUE other)
{
if (!rb_obj_is_kind_of(other, cPixelFormat))
return Qfalse;
return INT2BOOL(rb_iv_get(self, "@format") == rb_iv_get(other, "@format"));
}
|
#alpha? ⇒ Boolean
Return true if the pixel format have an alpha channel.
2731 2732 2733 2734 |
# File 'video.c', line 2731
static VALUE PixelFormat_alpha_p(VALUE self)
{
return INT2BOOL(SDL_ISPIXELFORMAT_ALPHA(NUM2UINT(rb_iv_get(self, "@format"))));
};
|
#bits_per_pixel ⇒ Integer Also known as: bpp
Get the number of bits per pixel.
2705 2706 2707 2708 |
# File 'video.c', line 2705
static VALUE PixelFormat_bits_per_pixel(VALUE self)
{
return INT2NUM(SDL_BITSPERPIXEL(NUM2UINT(rb_iv_get(self, "@format"))));
};
|
#bytes_per_pixel ⇒ Integer
Get the number of bytes per pixel.
2715 2716 2717 2718 |
# File 'video.c', line 2715
static VALUE PixelFormat_bytes_per_pixel(VALUE self)
{
return INT2NUM(SDL_BYTESPERPIXEL(NUM2UINT(rb_iv_get(self, "@format"))));
};
|
#fourcc? ⇒ Boolean
Return true if the pixel format is not indexed, and not RGB(A), for example, the pixel format is YUV.
2740 2741 2742 2743 |
# File 'video.c', line 2740
static VALUE PixelFormat_fourcc_p(VALUE self)
{
return INT2BOOL(SDL_ISPIXELFORMAT_FOURCC(NUM2UINT(rb_iv_get(self, "@format"))));
};
|
#indexed? ⇒ Boolean
Return true if the pixel format have a palette.
2723 2724 2725 2726 |
# File 'video.c', line 2723
static VALUE PixelFormat_indexed_p(VALUE self)
{
return INT2BOOL(SDL_ISPIXELFORMAT_INDEXED(NUM2UINT(rb_iv_get(self, "@format"))));
};
|
#inspect ⇒ String
Returns inspection string
2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 |
# File 'video.c', line 2760
static VALUE PixelFormat_inspect(VALUE self)
{
Uint32 format = NUM2UINT(rb_iv_get(self, "@format"));
return rb_sprintf("<%s: %s type=%d order=%d layout=%d"
" bits=%d bytes=%d indexed=%s alpha=%s fourcc=%s>",
rb_obj_classname(self),
SDL_GetPixelFormatName(format),
SDL_PIXELTYPE(format), SDL_PIXELORDER(format), SDL_PIXELLAYOUT(format),
SDL_BITSPERPIXEL(format), SDL_BYTESPERPIXEL(format),
INT2BOOLCSTR(SDL_ISPIXELFORMAT_INDEXED(format)),
INT2BOOLCSTR(SDL_ISPIXELFORMAT_ALPHA(format)),
INT2BOOLCSTR(SDL_ISPIXELFORMAT_FOURCC(format)));
}
|
#layout ⇒ Integer
Get the channel bit pattern of the pixel format.
2695 2696 2697 2698 |
# File 'video.c', line 2695
static VALUE PixelFormat_layout(VALUE self)
{
return UINT2NUM(SDL_PIXELLAYOUT(NUM2UINT(rb_iv_get(self, "@format"))));
};
|
#name ⇒ String
Get the human readable name of the pixel format
2675 2676 2677 2678 |
# File 'video.c', line 2675
static VALUE PixelFormat_name(VALUE self)
{
return utf8str_new_cstr(SDL_GetPixelFormatName(NUM2UINT(rb_iv_get(self, "@format"))));
};
|
#order ⇒ Integer
Get the ordering of channels or bits in the pixel format.
2685 2686 2687 2688 |
# File 'video.c', line 2685
static VALUE PixelFormat_order(VALUE self)
{
return UINT2NUM(SDL_PIXELORDER(NUM2UINT(rb_iv_get(self, "@format"))));
};
|
#type ⇒ Integer
Get the type of the format.
2661 2662 2663 2664 |
# File 'video.c', line 2661
static VALUE PixelFormat_type(VALUE self)
{
return UINT2NUM(SDL_PIXELTYPE(NUM2UINT(rb_iv_get(self, "@format"))));
}
|