def tile_encoder(**kwargs):
num_tiles = ((kwargs['<STR_LIT>'] / kwargs['<STR_LIT>']) *<EOL>(kwargs['<STR_LIT>'] / kwargs['<STR_LIT>']))<EOL>tile_size = ((kwargs['<STR_LIT>'] * kwargs['<STR_LIT>']) *<EOL>(kwargs['<STR_LIT>'] * kwargs['<STR_LIT>'] / <NUM_LIT:8>))<EOL>data = np.random.random((kwargs['<STR_LIT>'],<EOL>kwargs['<STR_LIT>'],<EOL>kwargs['<STR_LIT>']))<EOL>data = (data * <NUM_LIT:255>).astype(np.uint8)<EOL>l_param = openjp2.set_default_encoder_parameters()<EOL>l_param.tcp_numlayers = <NUM_LIT:1><EOL>l_param.cp_fixed_quality = <NUM_LIT:1><EOL>l_param.tcp_distoratio[<NUM_LIT:0>] = <NUM_LIT:20><EOL>l_param.cp_tx0 = <NUM_LIT:0><EOL>l_param.cp_ty0 = <NUM_LIT:0><EOL>l_param.tile_size_on = <NUM_LIT:1><EOL>l_param.cp_tdx = kwargs['<STR_LIT>']<EOL>l_param.cp_tdy = kwargs['<STR_LIT>']<EOL>l_param.irreversible = kwargs['<STR_LIT>']<EOL>l_param.numresolution = <NUM_LIT:6><EOL>l_param.prog_order = glymur.core.LRCP<EOL>l_params = (openjp2.ImageComptParmType * kwargs['<STR_LIT>'])()<EOL>for j in range(kwargs['<STR_LIT>']):<EOL><INDENT>l_params[j].dx = <NUM_LIT:1><EOL>l_params[j].dy = <NUM_LIT:1><EOL>l_params[j].h = kwargs['<STR_LIT>']<EOL>l_params[j].w = kwargs['<STR_LIT>']<EOL>l_params[j].sgnd = <NUM_LIT:0><EOL>l_params[j].prec = kwargs['<STR_LIT>']<EOL>l_params[j].x0 = <NUM_LIT:0><EOL>l_params[j].y0 = <NUM_LIT:0><EOL><DEDENT>codec = openjp2.create_compress(kwargs['<STR_LIT>'])<EOL>openjp2.set_info_handler(codec, None)<EOL>openjp2.set_warning_handler(codec, None)<EOL>openjp2.set_error_handler(codec, None)<EOL>cspace = openjp2.CLRSPC_SRGB<EOL>l_image = openjp2.image_tile_create(l_params, cspace)<EOL>l_image.contents.x0 = <NUM_LIT:0><EOL>l_image.contents.y0 = <NUM_LIT:0><EOL>l_image.contents.x1 = kwargs['<STR_LIT>']<EOL>l_image.contents.y1 = kwargs['<STR_LIT>']<EOL>l_image.contents.color_space = openjp2.CLRSPC_SRGB<EOL>openjp2.setup_encoder(codec, l_param, l_image)<EOL>stream = openjp2.stream_create_default_file_stream(kwargs['<STR_LIT:filename>'],<EOL>False)<EOL>openjp2.start_compress(codec, l_image, stream)<EOL>for j in np.arange(num_tiles):<EOL><INDENT>openjp2.write_tile(codec, j, data, tile_size, stream)<EOL><DEDENT>openjp2.end_compress(codec, stream)<EOL>openjp2.stream_destroy(stream)<EOL>openjp2.destroy_codec(codec)<EOL>openjp2.image_destroy(l_image)<EOL>
Fixture used by many tests.