clan::Image Alpha::create_block(clan::Canvas &canvas, const clan::Colorf &colour) { const int size = 24; clan::Color colour_int(colour); clan::ubyte8 colour_a = colour_int.a; clan::ubyte8 colour_r = colour_int.r; clan::ubyte8 colour_g = colour_int.g; clan::ubyte8 colour_b = colour_int.b; clan::PixelBuffer pbuff(size, size, clan::tf_rgba8); clan::ubyte8 *pixels = (clan::ubyte8 *) pbuff.get_data(); int pitch = pbuff.get_pitch(); for (int ypos = 0; ypos < size; ypos++) { clan::ubyte8 *dest_ptr = pixels + ypos * pitch; for (int xpos = 0; xpos < size; xpos++) { *(dest_ptr++) = colour_a; *(dest_ptr++) = colour_b; *(dest_ptr++) = colour_g; *(dest_ptr++) = colour_r; } } return clan::Image(canvas, pbuff, pbuff.get_size()); }
CL_PixelBuffer CL_PNGProvider::load(CL_IODevice &iodev) { CL_PNGProvider_Impl png(iodev); CL_PixelBuffer pbuff(png.width, png.height, png.sized_format, png.palette, png.get_data()); pbuff.set_colorkey(png.uses_src_colorkey(), png.get_src_colorkey()); return pbuff; }
CL_PixelBuffer CL_PNGProvider::load( const CL_String &filename, const CL_VirtualDirectory &directory) { CL_PNGProvider_Impl png(filename, directory); CL_PixelBuffer pbuff(png.width, png.height, png.sized_format, png.palette, png.get_data()); pbuff.set_colorkey(png.uses_src_colorkey(), png.get_src_colorkey()); return pbuff; }
PixelBuffer PerlinNoise_Impl::create_noise4d(float start_x, float end_x, float start_y, float end_y, float z_position, float w_position) { setup(); if (texture_format == tf_rgba8) { PixelBuffer pbuff(width, height, texture_format); PerlinNoise_PixelWriter_RGBA8 writer(pbuff); create_noise4d(writer, start_x, end_x, start_y, end_y, z_position, w_position); return pbuff; } if (texture_format == tf_rgb8) { PixelBuffer pbuff(width, height, texture_format); PerlinNoise_PixelWriter_RGB8 writer(pbuff); create_noise4d(writer, start_x, end_x, start_y, end_y, z_position, w_position); return pbuff; } if (texture_format == tf_r8) { PixelBuffer pbuff(width, height, texture_format); PerlinNoise_PixelWriter_R8 writer(pbuff); create_noise4d(writer, start_x, end_x, start_y, end_y, z_position, w_position); return pbuff; } if (texture_format == tf_r32f) { PixelBuffer pbuff(width, height, texture_format); PerlinNoise_PixelWriter_R32f writer(pbuff); create_noise4d(writer, start_x, end_x, start_y, end_y, z_position, w_position); return pbuff; } throw Exception("sized format is not supported"); }
clan::Image Alpha::create_block(clan::Canvas &canvas, const clan::Colorf &colour) { const int size = 24; clan::Color colour_int(colour); clan::PixelBuffer pbuff(size, size, clan::tf_rgba8); uint8_t *pixels = pbuff.get_data_uint8(); int pitch = pbuff.get_pitch(); for (int ypos = 0; ypos < size; ypos++) { uint8_t *dest_ptr = pixels + ypos * pitch; for (int xpos = 0; xpos < size; xpos++) { *(dest_ptr++) = colour_int.r; *(dest_ptr++) = colour_int.g; *(dest_ptr++) = colour_int.b; *(dest_ptr++) = colour_int.a; } } return clan::Image(canvas, pbuff, pbuff.get_size()); }