コード例 #1
0
ファイル: bitmap.c プロジェクト: BarlowRobert/PebbleLocalSim
void rot_bitmap_layer_update_func (Layer* l,GContext* ctx) {
    ROT_BITMAP_GET;
    GPoint topOffset=getTopOffset ();
    setTopOffset(GPoint(0,0));
    GRect rect=GRect(0,0,l->frame.size.w,l->frame.size.h);

    SDL_Surface* sur=createSurface(rotbitmap->bitmap->bounds.size.w,rotbitmap->bitmap->bounds.size.h);
    SDL_FillRect(sur,0,0);
    graphics_context_set_compositing_mode (ctx,GCompOpAssign);
    graphics_draw_bitmap_in_rect_to (ctx,rotbitmap->bitmap,rect,sur);
    double angle=(double)rotbitmap->rotation/TRIG_MAX_ANGLE*360.0;
    SDL_Surface* rotated=rotozoomSurface(sur,-angle,1.0,SMOOTHING_OFF);
    SDL_FreeSurface(sur);
    GPoint offset=getPivotRotationOffset(rotbitmap->bitmap->bounds.size,GSize(rotated->w,rotated->h),rotbitmap->src_ic,angle);

    rotbitmap->dest_ic.x=l->frame.size.w/2; //TODO: Verify this
    rotbitmap->dest_ic.y=l->frame.size.h/2;

    setTopOffset(topOffset);
    if (rotbitmap->corner_clip_color!=GColorClear) {
        graphics_context_set_fill_color(ctx,rotbitmap->corner_clip_color);
        graphics_fill_rect(ctx,GRect(0,0,l->frame.size.w,l->frame.size.h),0,0);
    }
    graphics_context_set_compositing_mode (ctx,rotbitmap->compositing_mode);
    graphics_draw_surface_in_rect (ctx,rotated,GRect(rotbitmap->dest_ic.x-offset.x,rotbitmap->dest_ic.y-offset.y,rotated->w,rotated->h));
    SDL_FreeSurface(rotated);
}
コード例 #2
0
ファイル: bitmap.c プロジェクト: AmandaCameron/PebbleLocalSim
void rotbmp_layer_update_func (Layer* me,GContext* ctx) {
    GPoint topOffset=getTopOffset ();
    setTopOffset(GPoint(0,0));
    GRect rect=GRect(0,0,me->frame.size.w,me->frame.size.h);
    RotBitmapLayer* bitmapLayer=(RotBitmapLayer*)me;

    SDL_Surface* bitmap=createSurface(bitmapLayer->bitmap->bounds.size.w,bitmapLayer->bitmap->bounds.size.h);
    SDL_FillRect(bitmap,0,0);
    graphics_context_set_compositing_mode (ctx,GCompOpAssign);
    graphics_draw_bitmap_in_rect_to (ctx,bitmapLayer->bitmap,rect,bitmap);
    double angle=(double)bitmapLayer->rotation/TRIG_MAX_ANGLE*360.0;
    SDL_Surface* rotated=rotozoomSurface(bitmap,-angle,1.0,SMOOTHING_OFF);
    SDL_FreeSurface(bitmap);
    GPoint offset=getPivotRotationOffset(bitmapLayer->bitmap->bounds.size,GSize(rotated->w,rotated->h),bitmapLayer->src_ic,angle);

    setTopOffset(topOffset);
    graphics_context_set_compositing_mode (ctx,bitmapLayer->compositing_mode);
    graphics_draw_surface_in_rect (ctx,rotated,GRect(bitmapLayer->dest_ic.x-offset.x,bitmapLayer->dest_ic.y-offset.y,rotated->w,rotated->h));
    SDL_FreeSurface(rotated);
}