Example #1
0
static int getpixel__nocheck(SDL_Surface *surf, int x, int y) {
	unsigned long addr = (unsigned long) surf->pixels + y * surf->pitch + x * surf->format->BytesPerPixel;
	switch(surf->format->BytesPerPixel) {
		case 1: return bmp_read8(addr);
		case 2: return bmp_read16(addr);
		case 3: return bmp_read24(addr);
		case 4: return bmp_read32(addr);
	}
	return 0;
}
Example #2
0
static int getpixel__nocheck(ALLEGRO_BITMAP *bmp, int x, int y) {
	unsigned long addr = (unsigned long) bmp->line[y] + x * bmp->surf->format->BytesPerPixel;
	switch(bmp->surf->format->BytesPerPixel) {
		case 1: return bmp_read8(addr);
		case 2: return bmp_read16(addr);
		case 3: return bmp_read24(addr);
		case 4: return bmp_read32(addr);
	}
	return 0;
}
/*
 * call-seq:
 *   bmp_read8(addr) -> str
 *
 */
VALUE a4r_API_bmp_read8(VALUE self, VALUE addr)
{
  return rb_str_new((char*)&(bmp_read8(NUM2ULONG(addr))), sizeof(uint8_t));
}