int main(void) { int w; int i; assert((win = bunny_start(800, 600, false, "The Lapins Noirs")) != NULL); assert((pic[0] = bunny_new_picture(NORM(800, 600), NORM(800, 600))) != NULL); assert((pic[1] = bunny_new_picture(NORM(800, 600), NORM(800, 600))) != NULL); assert((bunny = bunny_load_picture("bigbunny.png")) != NULL); bunny->origin.x = bunny->buffer.width / 2; bunny->origin.y = bunny->buffer.height / 2; pic[0]->origin.x = pic[0]->buffer.width / 2; pic[0]->origin.y = pic[0]->buffer.height / 2; pic[1]->origin.x = pic[1]->buffer.width / 2; pic[1]->origin.y = pic[1]->buffer.height / 2; bunny_clear(&pic[0]->buffer, 0); bunny_clear(&pic[1]->buffer, 0); for (i = 0, w = 50; i < pic[0]->buffer.width; i += 100) { square(pic[0], i, 0, w, pic[0]->buffer.height, ALPHA(150, rand())); square(pic[1], i, 0, w, pic[1]->buffer.height, ALPHA(150, rand())); } reset(pic[0]); reset(pic[1]); bunny_set_loop_main_function(loop); bunny_set_key_response(key); bunny_loop(win, 50, NULL); bunny_delete_clipable(pic[0]); bunny_delete_clipable(pic[1]); bunny_stop(win); return (EXIT_FAILURE); }
int main_rpc_warpabt(int c, char *v[]) { TIFFSetWarningHandler(NULL);//suppress warnings // input arguments if (c != 9) { fprintf(stderr, "usage:\n\t" "%s a.{tiff,rpc} b.{tiff,rpc} ax ay in.tif out.tif\n", *v); //0 1 2 3 4 5 6 7 8 return 1; } char *filename_a = v[1]; char *filename_rpca = v[2]; char *filename_b = v[3]; char *filename_rpcb = v[4]; double axyh[3] ={atof(v[5]), atof(v[6]), 0}; char *filename_h0 = v[7]; char *filename_out = v[8]; // read input images int megabytes = 800; struct tiff_tile_cache ta[1], tb[1]; tiff_tile_cache_init(ta, filename_a, megabytes); tiff_tile_cache_init(tb, filename_b, megabytes); int pd = ta->i->spp; if (pd != tb->i->spp) fail("image color depth mismatch\n"); // read input rpcs struct rpc rpca[1]; struct rpc rpcb[1]; read_rpc_file_xml(rpca, filename_rpca); read_rpc_file_xml(rpcb, filename_rpcb); // read initialized raster int w, h; float *in_h0 = iio_read_image_float(filename_h0, &w, &h); // allocate space for output raster float *out_h = xmalloc(w * h * sizeof*out_h); // run the algorithm float alpha2 = ALPHA()*ALPHA(); int niter = NITER(); int nwarps = NWARPS(); for (int i = 0; i < nwarps; i++) { mnehs_rpc(out_h, in_h0, w,h,ta,rpca,tb,rpcb,axyh, alpha2,niter); memcpy(in_h0, out_h, w*h*sizeof*in_h0); } // save the output raster iio_save_image_float(filename_out, out_h, w, h); // cleanup and exit free(in_h0); free(out_h); tiff_tile_cache_free(ta); tiff_tile_cache_free(tb); return 0; }
static void callback_common(unsigned num,rgba *pixels) { if( flatspec.transmap_filename ) { if( flatspec.partial_transparency_mode == ALLOW_PARTIAL_TRANSPARENCY ) { unsigned i ; if( transfile == NULL ) start_writing(&transfile,5); for( i=0; i < num; i++ ) putc( ALPHA(pixels[i]), transfile ); } else { if( transfile == NULL ) { start_writing(&transfile,4); } /* Partial transparency should have been caught in the flattener, * so just extract a single byte. */ put_pbm_row(transfile,num,pixels,(rgba)1 << ALPHA_SHIFT); } } else if( ALPHA(flatspec.default_pixel) < 128 ) { unsigned i ; for( i=0; i < num; i++ ) if( !FULLALPHA(pixels[i]) ) FatalGeneric(100,_("Transparency found, but -a option not given")); } xcffree(pixels) ; }
/*------------------------------------------------------------------------ * * PROTOTYPE : void CALLING_C TrspADDbit (int32_t x, int32_t y, GXSPRITE *sp) * * DESCRIPTION : * */ static void CALLING_C Trsp50 (int32_t x, int32_t y, GXSPRITE *sp) { GXSPRITESW *p = (GXSPRITESW*)sp->handle; uint8_t *v; int32_t oy=0, ox=0, lx=sp->LX, ly=sp->LY; int d = 0; /*=============================================================*/ SPRITE_CLIPPING /*=============================================================*/ v = g_pRLX->pGX->View.lpBackBuffer + g_pRLX->pGX->View.lPitch * y + sizeof(Tsize) * x; d = g_pRLX->pGX->View.lPitch - lx*sizeof(Tsize); if (p->bpp == sizeof(Tsize)) { Tsize *u = (Tsize*)sp->data + oy * (int32_t)sp->LX + ox; int i; for (i=0;i<ly;i++,v+=d, u+=sp->LX) { int j; for (j=0;j<lx;j++,v+=sizeof(Tsize)) ALPHA(v, u[j]); } } else if (p->bpp == 1) { uint8_t *u = (uint8_t*)sp->data + oy * (int32_t)sp->LX + ox; int i; for (i=0;i<ly;i++,v+=d, u+=sp->LX) { int j; for (j=0;j<lx;j++,v+=sizeof(Tsize)) ALPHA(v, p->palette[u[j]]); } } }
pixel_t compose_over(pixel_t fg, pixel_t bg) { double mul; double mul_cmp; double res_a; double res_r; double res_g; double res_b; if (ALPHA(bg) == 255) { res_a = 1; mul = ((double) ALPHA(fg)) / 255.0; mul_cmp = 1 - mul; } else { double fg_a = ((double) ALPHA(fg)) / 255.0; double bg_a = ((double) ALPHA(bg)) / 255.0; res_a = 1 - (1 - fg_a) * (1 - bg_a); mul = fg_a / res_a; mul_cmp = 1 - mul; } res_r = mul * ((double) RED(fg)) + mul_cmp * ((double) RED(bg)); res_g = mul * ((double) GREEN(fg)) + mul_cmp * ((double) GREEN(bg)); res_b = mul * ((double) BLUE(fg)) + mul_cmp * ((double) BLUE(bg)); return PIXEL((unsigned) (res_a * 255), (unsigned) res_r, (unsigned) res_g, (unsigned) res_b); }
int main_compute(int c, char *v[]) { // input arguments bool do_only_warp = pick_option(&c, &v, "w", NULL); if (do_only_warp) return main_warp(c, v); bool do_center = pick_option(&c, &v, "c", NULL); if (c != 7) { fprintf(stderr, "usage:\n\t" "%s a.png b.png Pa.txt Pb.txt in.tiff out.tiff\n", *v); // 0 1 2 3 4 5 6 return 1; } char *filename_a = v[1]; char *filename_b = v[2]; char *matrix_pa = v[3]; char *matrix_pb = v[4]; char *filename_in = v[5]; char *filename_out = v[6]; // read input images and matrices int wa, wb, wi, ha, hb, hi; float *a = iio_read_image_float(filename_a, &wa, &ha); float *b = iio_read_image_float(filename_b, &wb, &hb); float *h0 = iio_read_image_float(filename_in, &wi, &hi); double PA[8], PB[8]; read_n_doubles_from_string(PA, matrix_pa, 8); read_n_doubles_from_string(PB, matrix_pb, 8); // perform centering, if necessary if (do_center) { center_projection(PA, wa/2, ha/2); center_projection(PB, wb/2, hb/2); } // allocate space for output image float *out = xmalloc(wi * hi * sizeof*out); // run the algorithm float alpha2 = ALPHA()*ALPHA(); int niter = NITER(); int nwarps = NWARPS(); int nscales = NSCALES(); mnehs_affine_ms(out, h0, wi, hi, a, wa, ha, b, wb, hb, PA, PB, alpha2, niter, nscales); //for (int i = 0; i < nwarps; i++) //{ // mnehs_affine(out, h0, wi,hi, a,wa,ha, b,wb,hb, PA, PB, alpha2, niter); // memcpy(h0, out, wi * hi * sizeof*h0); //} // save the output image iio_save_image_float(filename_out, out, wi, hi); // cleanup and exit free(out); free(h0); free(a); free(b); return 0; }
ColorARGB GifTranscoder::computeAverage(ColorARGB c1, ColorARGB c2, ColorARGB c3, ColorARGB c4) { char avgAlpha = (char)(((int) ALPHA(c1) + (int) ALPHA(c2) + (int) ALPHA(c3) + (int) ALPHA(c4)) / 4); char avgRed = (char)(((int) RED(c1) + (int) RED(c2) + (int) RED(c3) + (int) RED(c4)) / 4); char avgGreen = (char)(((int) GREEN(c1) + (int) GREEN(c2) + (int) GREEN(c3) + (int) GREEN(c4)) / 4); char avgBlue = (char)(((int) BLUE(c1) + (int) BLUE(c2) + (int) BLUE(c3) + (int) BLUE(c4)) / 4); return MAKE_COLOR_ARGB(avgAlpha, avgRed, avgGreen, avgBlue); }
void * Alpha_assign (void * to, const void * from, y_Error ** error) { Alpha * alpha_to = ALPHA (to); const Alpha * alpha_from = ALPHA (from); if ( alpha_to && alpha_from ) { alpha_to->a = alpha_from->a; } return to; }
internal void PT_CopyBlend(u32 *destPixels, PT_Rect *destRect, u32 destPixelsPerRow, u32 *srcPixels, PT_Rect *srcRect, u32 srcPixelsPerRow, u32 *newColor) { // If src and dest rects are not the same size ==> bad things assert(destRect->w == srcRect->w && destRect->h == srcRect->h); // For each pixel in the destination rect, alpha blend to it the // corresponding pixel in the source rect. // ref: https://en.wikipedia.org/wiki/Alpha_compositing u32 stopX = destRect->x + destRect->w; u32 stopY = destRect->y + destRect->h; for (u32 dstY = destRect->y, srcY = srcRect->y; dstY < stopY; dstY++, srcY++) { for (u32 dstX = destRect->x, srcX = srcRect->x; dstX < stopX; dstX++, srcX++) { u32 srcColor = srcPixels[(srcY * srcPixelsPerRow) + srcX]; u32 *destPixel = &destPixels[(dstY * destPixelsPerRow) + dstX]; u32 destColor = *destPixel; // Colorize our source pixel before we blend it srcColor = PT_ColorizePixel(srcColor, *newColor); if (ALPHA(srcColor) == 0) { // Source is transparent - so do nothing continue; } else if (ALPHA(srcColor) == 255) { // Just copy the color, no blending necessary *destPixel = srcColor; } else { // Do alpha blending float srcA = ALPHA(srcColor) / 255.0; float invSrcA = (1.0 - srcA); float destA = ALPHA(destColor) / 255.0; float outAlpha = srcA + (destA * invSrcA); u8 fRed = ((RED(srcColor) * srcA) + (RED(destColor) * destA * invSrcA)) / outAlpha; u8 fGreen = ((GREEN(srcColor) * srcA) + (GREEN(destColor) * destA * invSrcA)) / outAlpha; u8 fBlue = ((BLUE(srcColor) * srcA) + (BLUE(destColor) * destA * invSrcA)) / outAlpha; u8 fAlpha = outAlpha * 255; *destPixel = COLOR_FROM_RGBA(fRed, fGreen, fBlue, fAlpha); } } } }
void omb_draw_rect(int x, int y, int width, int height, int color) { int i, j; long int location = 0; unsigned char alpha = ALPHA(color); unsigned char red = RED(color); unsigned char green = GREEN(color); unsigned char blue = BLUE(color); for (i = y; i < y + height; i++) { for (j = x; j < x + width; j++) { if (i < 0 || j < 0 || i > omb_var_screen_info.yres || j > omb_var_screen_info.xres) continue; location = ((j + omb_var_screen_info.xoffset) * (omb_var_screen_info.bits_per_pixel / 8)) + ((i + omb_var_screen_info.yoffset) * omb_fix_screen_info.line_length); *(omb_fb_map + location) = blue; *(omb_fb_map + location + 1) = green; *(omb_fb_map + location + 2) = red; *(omb_fb_map + location + 3) = alpha; } } }
internal inline u32 PT_ColorizePixel(u32 dest, u32 src) { // Colorize the destination pixel using the source color if (ALPHA(dest) == 255) { return src; } else if (ALPHA(dest) > 0) { // Scale the final alpha based on both dest & src alphas return COLOR_FROM_RGBA(RED(src), GREEN(src), BLUE(src), (u8)(ALPHA(src) * (ALPHA(dest) / 255.0))); } else { return dest; } }
static t_bunny_response loop(void *data) { t_bunny_position pos; t_bunny_position mid; (void)data; bunny_fill(&win->buffer, ALPHA(32, BLACK)); pos.x = win->buffer.width / 2; pos.y = win->buffer.height / 2; pic[0]->rotation = rotation; pic[1]->rotation = rotation + cos(8 * rotation * M_PI / 180.0); pic[0]->scale.x = 2 + cos(scale * M_PI / 180.0); pic[0]->scale.y = 2 + cos(scale * M_PI / 180.0); pic[1]->scale.x = 2.2 + sin(scale2 * M_PI / 180.0); pic[1]->scale.y = 2.2 + sin(scale2 * M_PI / 180.0); rotation += 1; scale += 2; scale2 -= 1; mid.x = win->buffer.width / 2; mid.y = win->buffer.height / 2; bunny->rotation = -rotation * 2; bunny->scale.x = 2 - cos(scale * M_PI / 180.0); bunny->scale.y = 2 + sin(scale * M_PI / 180.0); bunny_blit(&win->buffer, pic[0], &pos); bunny_blit(&win->buffer, bunny, &mid); bunny_blit(&win->buffer, pic[1], &pos); bunny_display(win); return (GO_ON); }
/* * See Figure 11-2, "The Hungarian method", page 251. * * Corresponds to lines 26--27, 38--39. * Called by hm_pre_search() and hm_search(). */ static void hm_update_slack( hm_data *hm, int z ) { int k, tmp; for EACH_U( k ) { tmp = C( z, k ) - ALPHA( z ) - BETA( k ); if ( 0 <= tmp && tmp < SLACK( k ) ) { SLACK( k ) = tmp; /* * The following decrement and increment are necessary to maintain * the count[] array, which is not included in the original Figure * 11-2 implementation, and whose addition and purpose are described * above in hm_construct_auxiliary_graph(). */ if ( NHBOR( k ) != blank ) { --COUNT( NHBOR( k ) ); } ++COUNT( z ); NHBOR( k ) = z; } } }
void draw3DLine(float sx, float sy, float sz, float ex, float ey, float ez, DWORD colour) { glLoadIdentity(); /*D3DXMATRIX mat; D3DXMatrixIdentity(&mat); g_pd3dDevice->SetTransform( D3DTS_WORLD, &mat ); // Move object */ DWORD &c = colour; float c1[4] ={ ((float)RED(c)) / 255.0f, ((float)GREEN(c)) / 255.0f, ((float)BLUE(c)) / 255.0f, ((float)ALPHA(c)) / 255.0f }; glColor4fv(c1); glBegin(GL_LINES); // glColor4f(RED(colour), GREEN(colour), BLUE(colour), ALPHA(colour)); glVertex3f(sx, sy, sz); glVertex3f(ex, ey, ez); glEnd(); /* #define D3DFVF_LVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE) struct LVERTEX { float x, y, z; DWORD diffuse; }; LVERTEX line[2] = { { sx, sy, sz, colour }, { ex, ey, ez, colour } }; SetVertexShader( D3DFVF_LVERTEX ); g_pd3dDevice->DrawPrimitiveUP(D3DPT_LINELIST, 2, line, sizeof(LVERTEX)); */ }
/* void draw2DBox(int top, int left, int right, int bottom, DWORD colour[4]) { CONTROLVERTEX Vertices[4] = { // x, y, z, rhw, colour, tu,tv { left, bottom, 0.0f, 1.0f, colour[0], 0.0f, 1.0f }, // BL { right, bottom, 0.0f, 1.0f, colour[2], 1.0f, 1.0f }, // BR { left, top, 0.0f, 1.0f, colour[1], 0.0f, 0.0f }, // TL { right, top, 0.0f, 1.0f, colour[3], 1.0f, 0.0f }, // TR }; glBegin(GL_TRIANGLE_STRIP); for (int i = 0; i < 4; ) { DWORD &c = Vertices[i].diffuse; float c1[4] ={ ((float)RED(c)) / 255.0, ((float)GREEN(c)) / 255.0, ((float)BLUE(c)) / 255.0, ((float)ALPHA(c)) / 255.0 }; glColor4fv(c1); glTexCoord2d(Vertices[i].tu0,Vertices[i].tv0); glVertex3f(Vertices[i].x, Vertices[i].y, Vertices[i].z); i++; } glEnd(); } */ void draw2DBox(float top, float left, float right, float bottom, DWORD colour[4]) { CONTROLVERTEX Vertices[4] = { // x, y, z, rhw, colour, tu,tv { left, bottom, 0.0f, 1.0f, colour[0], 0.0f, 1.0f }, // BL { right, bottom, 0.0f, 1.0f, colour[2], 1.0f, 1.0f }, // BR { left, top, 0.0f, 1.0f, colour[1], 0.0f, 0.0f }, // TL { right, top, 0.0f, 1.0f, colour[3], 1.0f, 0.0f }, // TR }; glBegin(GL_TRIANGLE_STRIP); for (int i = 0; i < 4; ) { DWORD &c = Vertices[i].diffuse; float c1[4] ={ ((float)RED(c)) / 255.0f, ((float)GREEN(c)) / 255.0f, ((float)BLUE(c)) / 255.0f, ((float)ALPHA(c)) / 255.0f }; glColor4fv(c1); glTexCoord2d(Vertices[i].tu0,Vertices[i].tv0); glVertex3f(Vertices[i].x, Vertices[i].y, Vertices[i].z); i++; } glEnd(); }
static float *twiddles_step_64(double two_pi, float *out, double theta) { int i; for (i=0; i<32; i++) { *out++ = ALPHA(theta); *out++ = BETA(theta); } return twiddles_step_32(two_pi, out, 2*theta); }
void fs_beam(int t) { int h = 64+8+384-t*4; if ( h < 0 ) h = 0; GFX_POLY_FORMAT = LIGHT0|POLYFRONT|ALPHA(15); spot(RGB15(0, 31, 4), RGB15(0, 31, 4), -32, h-384); }
static float *twiddles_step_16(double two_pi, float *out, double theta) { int i; for (i=0; i<16; i++) { *out++ = ALPHA(theta*k[i]); *out++ = BETA(theta*k[i]); } return out; }
void Alpha_clear (void * self, bool unref_objects) { Alpha * alpha = ALPHA (self); if ( alpha ) { alpha->a = 0; } }
void omb_draw_rounded_rect(int x, int y, int width, int height, int color, int radius) { int i, j; long int location = 0; unsigned char alpha = ALPHA(color); unsigned char red = RED(color); unsigned char green = GREEN(color); unsigned char blue = BLUE(color); for (i = y; i < y + height; i++) { for (j = x; j < x + width; j++) { if (i < 0 || j < 0 || i > omb_var_screen_info.yres || j > omb_var_screen_info.xres) continue; int relative_x = j - x; int relative_y = i - y; // top left corner if (relative_y < radius && relative_x < radius) { if (!omb_is_point_inside_circle(relative_x, relative_y, radius)) { continue; } } // top right corner else if (relative_y < radius && width - relative_x < radius) { if (!omb_is_point_inside_circle(width - relative_x, relative_y, radius)) { continue; } } // bottom left corner else if (height - relative_y < radius && relative_x < radius) { if (!omb_is_point_inside_circle(relative_x, height - relative_y, radius)) { continue; } } // bottom right corner else if (height - relative_y < radius && width - relative_x < radius) { if (!omb_is_point_inside_circle(width - relative_x, height - relative_y, radius)) { continue; } } location = ((j + omb_var_screen_info.xoffset) * (omb_var_screen_info.bits_per_pixel / 8)) + ((i + omb_var_screen_info.yoffset) * omb_fix_screen_info.line_length); *(omb_fb_map + location) = blue; *(omb_fb_map + location + 1) = green; *(omb_fb_map + location + 2) = red; *(omb_fb_map + location + 3) = alpha; } } }
internal void PT_FillBlend(u32 *pixels, u32 pixelsPerRow, PT_Rect *destRect, u32 color) { // For each pixel in the destination rect, alpha blend the // bgColor to the existing color. // ref: https://en.wikipedia.org/wiki/Alpha_compositing u32 stopX = destRect->x + destRect->w; u32 stopY = destRect->y + destRect->h; // If the color we're trying to blend is transparent, then bail if (ALPHA(color) == 0) return; float srcA = ALPHA(color) / 255.0; float invSrcA = 1.0 - srcA; // Otherwise, blend each pixel in the dest rect for (u32 dstY = destRect->y; dstY < stopY; dstY++) { for (u32 dstX = destRect->x; dstX < stopX; dstX++) { u32 *pixel = &pixels[(dstY * pixelsPerRow) + dstX]; if (ALPHA(color) == 255) { // Just copy the color, no blending necessary *pixel = color; } else { // Do alpha blending u32 pixelColor = *pixel; float destA = ALPHA(pixelColor) / 255.0; float outAlpha = srcA + (destA * invSrcA); u8 fRed = ((RED(color) * srcA) + (RED(pixelColor) * destA * invSrcA)) / outAlpha; u8 fGreen = ((GREEN(color) * srcA) + (GREEN(pixelColor) * destA * invSrcA)) / outAlpha; u8 fBlue = ((BLUE(color) * srcA) + (BLUE(pixelColor) * destA * invSrcA)) / outAlpha; u8 fAlpha = outAlpha * 255; *pixel = COLOR_FROM_RGBA(fRed, fGreen, fBlue, fAlpha); } } } }
bool aimbot::DoStateCheck(CBaseEntity* pl) { if (!pl->IsAlive()) return 0; if (Ignore(pl)) return 0; if (tf2()) { if (pl->TF2_IsUbercharged()) return 0; if (pl->TF2_HasCond(PlayerCond_Bonked)) return 0; // TODO: Find better way to check if it's invulnerable //if (pl->TF2_GetClassNum() == Class_Demoman && pl->GetHealth() == 1 && // !strcmp(mdlinfo->GetModelName(pl->GetModel()), "models/bots/demo/bot_sentry_buster.mdl")) // // return false; } if (MENU_SPAWPROT == 1 && ALPHA(pl->GetMDLColor()) == 128) return 0; if (MENU_SPAWPROT == 2 && pl->GetHealth() > 500) return 0; if (MENU_SPAWPROT == 3 && ALPHA(pl->GetMDLColor()) == 200) return 0; if (!MENU_STEAMBRO && pl->IsSteamFriend()) return 0; return 1; }
void hippo_cairo_set_source_rgba32(cairo_t *cr, guint32 color) { /* trying to avoid alpha 255 becoming a double alpha that isn't quite opaque ? * not sure this is needed. */ if ((color & 0xff) == 0xff) { cairo_set_source_rgb(cr, RED(color), GREEN(color), BLUE(color)); } else { cairo_set_source_rgba(cr, RED(color), GREEN(color), BLUE(color), ALPHA(color)); } }
static lineCallback selectCallback(void) { if( flatspec.transmap_filename && ALPHA(flatspec.default_pixel) >= 128 ) FatalGeneric(101,_("The -a option was given, " "but the image has no transparency")); switch( flatspec.out_color_mode ) { default: case COLOR_RGB: return &ppm_callback ; case COLOR_GRAY: return &pgm_callback ; case COLOR_MONO: return &pbm_callback ; } }
/* * See Figure 11-2, "The Hungarian method", page 251. * * Corresponds to lines 12--17. */ static void hm_construct_auxiliary_graph( hm_data *hm ) { int i, j; A.size = 0; for EACH_V( i ) { EXPOSED( i ) = blank; LABEL( i ) = blank; /* * The following data structure is not included in the Figure 11-2 * pseudo-code implementation. It has been added to account for * "labeling" on certain vertices described within Example 11.1 that * would otherwise be missing from the Figure 11-2 implementation. * * count[v] for any v \in V is equal to the size of the set * { u \in U : nhbor[u] = v }. When this set is non-empty, v is * considered to be "labeled". The use of this new data structure is * only to complete the conditional check on "labeled" statuses when * updating alpha within "procedure modify". */ COUNT( i ) = 0; } for EACH_U( j ) { SLACK( j ) = INT_MAX; /* * The following initialization of nhbor[] is necessary for proper usage * of the count[] array, whose addition and purpose is described above. */ NHBOR( j ) = blank; } for EACH_V( i ) { for EACH_U( j ) { if ( ALPHA( i ) + BETA( j ) == C( i, j ) ) { if ( MATE( j ) == blank ) { EXPOSED( i ) = j; } else if ( i != MATE( j ) ) { add_arc( &A, i, MATE( j ) ); } } } } }
pixel_t source_determine_pixel(source_t *source, double x, double y) { if (source->mask || source->texture) { transform_apply_affine(&source->transform, &x, &y); } pixel_t mask_pix; if (source->mask) { mask_pix = source->filter( surface_pixmap_access(source->mask), x, y, source->mask_tile); } else { mask_pix = source->alpha; } if (!ALPHA(mask_pix)) { return 0; } pixel_t texture_pix; if (source->texture) { texture_pix = source->filter( surface_pixmap_access(source->texture), x, y, source->texture_tile); } else { texture_pix = source->color; } if (ALPHA(mask_pix) < 255) { double ratio = ((double) ALPHA(mask_pix)) / 255.0; double res_a = ratio * ((double) ALPHA(texture_pix)); return PIXEL((unsigned) res_a, RED(texture_pix), GREEN(texture_pix), BLUE(texture_pix)); } else { return texture_pix; } }
static void graying_callback(unsigned num, rgba *pixels) { png_bytep fillptr = (uint8_t *)pixels ; unsigned i ; for( i = 0 ; i < num ; i++ ) { rgba pixel = pixels[i] ; int g = degrayPixel(pixel) ; if( g == -1 ) FatalGeneric(103, _("Grayscale output selected, but colored pixel(s) found")); *fillptr++ = g ; *fillptr++ = ALPHA(pixel) ; } raw_callback(num,pixels); }
/* * This function is for debugging purposes. It prints the algorithm's internal * state in a format similar to that of Example 11.1 (The matrix form of the * Hungarian method) beginning on page 252. * * The formatted output coded here is intended for small numbers. */ static void hm_print( hm_data *hm ) { int i, j, k; printf( "\n a\\b |" ); for EACH_U( j ) { printf( "%3d ", BETA( j ) ); } printf( "mate exposed label\n" ); printf( "-----+" ); for EACH_U( j ) { printf( "----" ); } printf( "------------------\n" ); for EACH_V( i ) { printf( " |\n %3d |", ALPHA( i ) ); for EACH_U( j ) { printf( "%3d ", C( i, j ) ); } printf( "%4d %7d %5d\n", MATE( i ), EXPOSED( i ), LABEL( i ) ); } printf( "\nslack" ); for EACH_U( j ) { printf( " %3d", SLACK( j ) == INT_MAX ? -1 : SLACK( j ) ); } printf( "\nnhbor" ); for EACH_U( j ) { printf( " %3d", NHBOR( j ) ); } printf( "\n\nA = { " ); for ( k = 0; k < A.size; ++k ) { printf( "(%d,%d) ", A.data[ k ].x, A.data[ k ].y ); } printf( "}\nQ = { " ); for ( k = 0; k < Q.size; ++k ) { printf( "%d ", Q.data[ k ] ); } printf( "}\n\n" ); }
/* Calculate all the coefficients as specified in the bands[] array */ void calc_coeffs() { int i, n; double f1, f2; double x0; n = 0; for (; bands[n].cfs; n++) { double *freqs = (double *)bands[n].cfs; for (i=0; i<bands[n].band_count; i++) { /* Find -3dB frequencies for the center freq */ find_f1_and_f2(freqs[i], bands[n].octave, &f1, &f2); /* Find Beta */ if ( find_root( BETA2(TETA(freqs[i]), TETA(f1)), BETA1(TETA(freqs[i]), TETA(f1)), BETA0(TETA(freqs[i]), TETA(f1)), &x0) == 0) { /* Got a solution, now calculate the rest of the factors */ /* Take the smallest root always (find_root returns the smallest one) * * NOTE: The IIR equation is * y[n] = 2 * (alpha*(x[n]-x[n-2]) + gamma*y[n-1] - beta*y[n-2]) * Now the 2 factor has been distributed in the coefficients */ /* Now store the coefficients */ bands[n].coeffs[i].beta = 2.0 * x0; bands[n].coeffs[i].alpha = 2.0 * ALPHA(x0); bands[n].coeffs[i].gamma = 2.0 * GAMMA(x0, TETA(freqs[i])); #ifdef DEBUG printf("Freq[%d]: %f. Beta: %.10e Alpha: %.10e Gamma %.10e\n", i, freqs[i], bands[n].coeffs[i].beta, bands[n].coeffs[i].alpha, bands[n].coeffs[i].gamma); #endif } else { /* Shouldn't happen */ bands[n].coeffs[i].beta = 0.; bands[n].coeffs[i].alpha = 0.; bands[n].coeffs[i].gamma = 0.; printf(" **** Where are the roots?\n"); } }// for i }//for n }
/* This part is unclear. I am unable to use buffered/FIFO based writes * to lcd. Depending on settings of IF I get various patterns on display * but not what I want to display apparently. */ static void lcdctrl_init(void) { /* alpha b111 * stop at current frame complete * MCU mode * 24b RGB */ LCDC_CTRL = ALPHA(7) | LCDC_STOP | LCDC_MCU | RGB24B; MCU_CTRL = ALPHA_BASE(0x3f) | MCU_CTRL_BYPASS; HOR_ACT = LCD_WIDTH + 3; /* define horizonatal active region */ VERT_ACT = LCD_HEIGHT; /* define vertical active region */ VERT_PERIOD = 0xfff; /* CSn/WEn/RDn signal timings */ LINE0_YADDR = LINE_ALPHA_EN | 0x7fe; LINE1_YADDR = LINE_ALPHA_EN | ((1 * LCD_WIDTH) - 2); LINE2_YADDR = LINE_ALPHA_EN | ((2 * LCD_WIDTH) - 2); LINE3_YADDR = LINE_ALPHA_EN | ((3 * LCD_WIDTH) - 2); LINE0_UVADDR = 0x7fe + 1; LINE1_UVADDR = ((1 * LCD_WIDTH) - 2 + 1); LINE2_UVADDR = ((2 * LCD_WIDTH) - 2 + 1); LINE3_UVADDR = ((3 * LCD_WIDTH) - 2 + 1); #if 0 LINE0_YADDR = 0; LINE1_YADDR = (1 * LCD_WIDTH); LINE2_YADDR = (2 * LCD_WIDTH); LINE3_YADDR = (3 * LCD_WIDTH); LINE0_UVADDR = 1; LINE1_UVADDR = (1 * LCD_WIDTH) + 1; LINE2_UVADDR = (2 * LCD_WIDTH) + 1; LINE3_UVADDR = (3 * LCD_WIDTH) + 1; START_X = 0; START_Y = 0; DELTA_X = 0x200; /* no scaling */ DELTA_Y = 0x200; /* no scaling */ #endif LCDC_INTR_MASK = INTR_MASK_LINE; /* INTR_MASK_EVENLINE; */ }