Class: SDL2::PixelFormat

Inherits:
Object
  • Object
show all
Defined in:
video.c

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)

Instance Method Summary (collapse)

Constructor Details

- (Object) initialize



2477
2478
2479
2480
2481
# File 'video.c', line 2477

static VALUE PixelForamt_initialize(VALUE self, VALUE format)
{
    rb_iv_set(self, "@format", format);
    return Qnil;
}

Instance Attribute Details

- (Object) format (readonly)

Instance Method Details

- (boolean) ==(other)

Return true if two pixel format is the same format.

Returns:

  • (boolean)


2573
2574
2575
2576
2577
2578
2579
# File 'video.c', line 2573

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"));
}

- (Boolean) alpha?

Return true if the pixel format have an alpha channel.

Returns:

  • (Boolean)


2553
2554
2555
2556
# File 'video.c', line 2553

static VALUE PixelFormat_alpha_p(VALUE self)
{
    return INT2BOOL(SDL_ISPIXELFORMAT_ALPHA(NUM2UINT(rb_iv_get(self, "@format"))));
};

- (Integer) bits_per_pixel Also known as: bpp

Get the number of bits per pixel.

Returns:

  • (Integer)


2527
2528
2529
2530
# File 'video.c', line 2527

static VALUE PixelFormat_bits_per_pixel(VALUE self)
{
    return INT2NUM(SDL_BITSPERPIXEL(NUM2UINT(rb_iv_get(self, "@format"))));
};

- (Integer) bytes_per_pixel

Get the number of bytes per pixel.

Returns:

  • (Integer)


2537
2538
2539
2540
# File 'video.c', line 2537

static VALUE PixelFormat_bytes_per_pixel(VALUE self)
{
    return INT2NUM(SDL_BYTESPERPIXEL(NUM2UINT(rb_iv_get(self, "@format"))));
};

- (Boolean) fourcc?

Return true if the pixel format is not indexed, and not RGB(A), for example, the pixel format is YUV.

Returns:

  • (Boolean)


2562
2563
2564
2565
# File 'video.c', line 2562

static VALUE PixelFormat_fourcc_p(VALUE self)
{
    return INT2BOOL(SDL_ISPIXELFORMAT_FOURCC(NUM2UINT(rb_iv_get(self, "@format"))));
};

- (Boolean) indexed?

Return true if the pixel format have a palette.

Returns:

  • (Boolean)


2545
2546
2547
2548
# File 'video.c', line 2545

static VALUE PixelFormat_indexed_p(VALUE self)
{
    return INT2BOOL(SDL_ISPIXELFORMAT_INDEXED(NUM2UINT(rb_iv_get(self, "@format"))));
};

- (String) inspect

Returns inspection string

Returns:

  • (String)

    inspection string



2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
# File 'video.c', line 2582

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)));
}

- (Integer) layout

Get the channel bit pattern of the pixel format.

Returns:

  • (Integer)


2517
2518
2519
2520
# File 'video.c', line 2517

static VALUE PixelFormat_layout(VALUE self)
{
    return UINT2NUM(SDL_PIXELLAYOUT(NUM2UINT(rb_iv_get(self, "@format"))));
};

- (String) name

Get the human readable name of the pixel format

Returns:

  • (String)


2497
2498
2499
2500
# File 'video.c', line 2497

static VALUE PixelFormat_name(VALUE self)
{
    return utf8str_new_cstr(SDL_GetPixelFormatName(NUM2UINT(rb_iv_get(self, "@format"))));
};

- (Integer) order

Get the ordering of channels or bits in the pixel format.

Returns:

  • (Integer)


2507
2508
2509
2510
# File 'video.c', line 2507

static VALUE PixelFormat_order(VALUE self)
{
    return UINT2NUM(SDL_PIXELORDER(NUM2UINT(rb_iv_get(self, "@format"))));
};

- (Object) type



2483
2484
2485
2486
# File 'video.c', line 2483

static VALUE PixelFormat_type(VALUE self)
{
    return UINT2NUM(SDL_PIXELTYPE(NUM2UINT(rb_iv_get(self, "@format"))));
}