Exemplo n.º 1
0
static MENU_UPDATE_FUNC(script_print)
{
    if (!script_preview_flag || !entry->selected)
    {
        MENU_SET_NAME("Show script");
        MENU_SET_VALUE("");
        script_preview_flag = 0;
        return;
    }
    
    static int prev_script = -1;

    if (prev_script != script_selected)
    {
        int size;
        char* p = get_script_path(script_selected);
        char* f = (char*)read_entire_file(p, &size);
        if (f)
        {
            script_copy_window(script_preview, sizeof(script_preview), f, 0, 0, 20, 60);
            fio_free(f);
        }
        else
        {
            snprintf(script_preview, sizeof(script_preview), "Could not read '%s'", p);
        }
    }
    prev_script = script_selected;

    bmp_fill(40, 0, 0, 720, 430);
    int fnt = FONT(FONT_MED, COLOR_WHITE, 40);
    big_bmp_printf(fnt, 10, 10, "%s", script_preview);

    info->custom_drawing = CUSTOM_DRAW_THIS_MENU;
}
Exemplo n.º 2
0
BMP_FILE bmp_fill_wrapper (char *name)
{
	BMP_FILE b = bmp_init();
	FILE *f = fopen(name, "rb");
	bmp_fill (b, f);
	fclose (f);

	return b;
}
Exemplo n.º 3
0
void 
draw_help_not_installed_page()
{
    bmp_fill(COLOR_BLACK, 0, 0, 720, 480);

    bfnt_puts("Help files not found", 10, 20, COLOR_WHITE, COLOR_BLACK);
    
    bmp_printf(FONT_MED, 10, 150, "Magic Lantern help files could not be found.              ");

    bmp_printf(FONT_MED, 10, 200, "Make sure all ML files are installed to your card.        ");

    bmp_printf(FONT_MED, 10, 250, "See http://wiki.magiclantern.fm/install for instructions. ");
}
Exemplo n.º 4
0
void 
draw_404_page()
{
    bmp_fill(COLOR_BLACK, 0, 0, 720, 480);

    bfnt_puts("404 Undocumented Feature", 10, 20, COLOR_WHITE, COLOR_BLACK);
    
    bmp_printf(FONT_MED, 10, 100, "This feature is probably not yet documented.");
    bmp_printf(FONT_MED, 10, 120, "After all, we are programmers, not tech writers.");

    bmp_printf(FONT_MED, 10, 180, "But... you can simply try it and see what it does.");

    bmp_printf(FONT_MED, 10, 240, "Then, write a short paragraph to describe it,");
    bmp_printf(FONT_MED, 10, 260, "and we will include it in the user guide.");

    bmp_printf(FONT_MED, 10, 320, "Thanks!");

}
Exemplo n.º 5
0
void 
draw_beta_warning()
{
    bmp_fill(COLOR_BLACK, 0, 0, 720, 480);

    bfnt_puts("Magic Lantern", 242, 53, COLOR_WHITE, COLOR_BLACK);

    bmp_printf(FONT_MED, 50, 150, "This is a development snapshot for testing purposes.");

    bmp_printf(FONT_MED, 50, 200, "   Please report all bugs at www.magiclantern.fm.   ");

    bmp_printf(FONT_MED, 50, 250, "      Be careful using it for production work.      ");

    bmp_printf(FONT_MED, 50, 300, "                       Enjoy!                       ");

    big_bmp_printf(FONT_MED,  10,  410,
        "Magic Lantern version : %s\n"
        "Mercurial changeset   : %s\n"
        "Built on %s by %s.",
        build_version,
        build_id,
        build_date,
        build_user);
}
Exemplo n.º 6
0
void display_shooting_info() // called from debug task
{
    if (lv) return;

    #ifdef FEATURE_FLEXINFO
    // from flexinfo.c
    info_print_screen();
    #endif

    // the following is stuff not yet ported to flexinfo
    #ifdef FEATURE_LCD_SENSOR_REMOTE
    display_lcd_remote_icon(555, 460);
    #endif
    
    // hack for Rebel cameras to display intermediate ISOs
    iso_refresh_display();
    
    display_trap_focus_info();

#ifdef STROBO_READY_AND_WE_CAN_USE_IT
    int col_field = bmp_getpixel(20,10);
    if (flash_info.mode==STROBO_FLASH_MODE_MANUAL)
    {
        uint32_t fntl = FONT(FONT_LARGE, COLOR_YELLOW, col_field);
        fnt = FONT(FONT_SMALL, COLOR_CYAN, col_field);
        bmp_printf(fnt, 488, 188, "A");
        bmp_printf(fntl, 498, 185, "%3d", 1 << flash_info.group_a_output);
        bmp_printf(fnt, 556, 188, "B");
        bmp_printf(fntl, 564, 185, "%3d", 1 << flash_info.group_b_output );
        bmp_printf(fnt, 624, 188, "C");
        bmp_printf(fntl, 632, 185, "%3d", 1 << flash_info.group_c_output);
        bmp_fill(col_bg,486,212,212,6);
    }
#endif

}
Exemplo n.º 7
0
static void update_graph()
{
    exposure last_expo;
    bool draw_label = 0;
    
    //bg rect
    bmp_fill(GRAPH_BG, 1,
        GRAPH_YOFF - GRAPH_MAX_PX - GRAPH_PADD,
        720 - 2,
        GRAPH_MAX_PX + GRAPH_TEXT_PADD + GRAPH_PADD + font_med.height
    );
    
    // current BV
    if(last_bv != INT_MIN){
        int x = GRAPH_XOFF + (BV_MAX - last_bv) * GRAPH_XSIZE;
        draw_line(x - 1, GRAPH_YOFF - GRAPH_MAX_PX,
            x - 1, GRAPH_YOFF, IS_SEL(browse) ? COLOR_WHITE : COLOR_CYAN);
        draw_line(x + 1, GRAPH_YOFF - GRAPH_MAX_PX,
            x + 1, GRAPH_YOFF, IS_SEL(browse) ? COLOR_WHITE : COLOR_CYAN);
    }
    
    graph_draw:
    last_expo = (exposure){-1, -1, -1, -1};
    for(int bv = BV_MAX; bv >= BV_MIN; bv -= (draw_label) ? 20 : GRAPH_STEP)
    {
        int x = GRAPH_XOFF + (BV_MAX - bv) * GRAPH_XSIZE;
        
        exposure expo =  get_exposure(bv, 1);
        int ec_val = expo.ec;
        expo.ec = (GRAPH_MAX / 2) + expo.ec;
        
        if(!draw_label) {
            int x_last = x - GRAPH_XSIZE * GRAPH_STEP;
            
            // bg lines
            if(!(bv % 10))draw_line(x, GRAPH_YOFF - GRAPH_MAX_PX, x, GRAPH_YOFF, COLOR_BLACK);
            
            // sv curve
            GRAPH_DRAW_CURVE(sv, COLOR_LIGHT_BLUE);
            
            // av curve
            GRAPH_DRAW_CURVE(av, COLOR_GREEN2);
            
            // ec curve
            GRAPH_DRAW_CURVE(ec,
                (last_expo.ec - (GRAPH_MAX / 2) == 0 && ec_val == 0) ? COLOR_BLACK : COLOR_ORANGE);
            
            // tv curve
            GRAPH_DRAW_CURVE(tv, COLOR_RED);
            
        } else {
            // bv value
            {
                char bv_str[3];
                snprintf(bv_str, sizeof(bv_str), "%d", ABS(bv / 10));
                int center = strlen(bv_str) * font_med.width / 2;
                if(bv < 0) center += font_med.width;
                bmp_printf(GRAPH_FONT, x + 3 - center, GRAPH_YOFF + GRAPH_TEXT_PADD, "%d", bv / 10);
            }
            
            //do not print on the right edge of graph
            if(BV_MAX + bv <= 40) continue;
            
            // sv value
            if(expo.sv != last_expo.sv) {
                bmp_printf(GRAPH_FONT, x, GRAPH_Y_TEXT(expo.sv), "%d", raw2iso(SV2RAW(expo.sv)));
            }
            
            // av value
            if(expo.av != last_expo.av) {
                int ap = AV2STR(expo.av);
                bmp_printf(GRAPH_FONT, x, GRAPH_Y_TEXT(expo.av), "%d.%d", ap / 10, ap % 10);
            }
            
            // ec value
            if(expo.ec != last_expo.ec && ec_val) {
                bmp_printf(GRAPH_FONT, x, GRAPH_Y_TEXT(expo.ec),
                    "%s%d.%d", FMT_FIXEDPOINT1S(ec_val));
            }
            
            // tv value
            if(expo.tv != last_expo.tv) {
                bmp_printf(GRAPH_FONT, x, GRAPH_Y_TEXT(expo.tv),
                    "%s", lens_format_shutter(TV2RAW(expo.tv)));
            }
            
        }
        
        last_expo = expo;
    }
    
    if(!draw_label) {
        draw_label = 1;
        goto graph_draw;
    }
}
Exemplo n.º 8
0
void k2pdfopt_reflow_bmp(KOPTContext *kctx) {
    K2PDFOPT_SETTINGS _k2settings, *k2settings;
    MASTERINFO _masterinfo, *masterinfo;
    WILLUSBITMAP _srcgrey, *srcgrey;
    WILLUSBITMAP *src, *dst;
    BMPREGION region;
    int i, bw, marbot, marleft;

    src = &kctx->src;
    srcgrey = &_srcgrey;
    bmp_init(srcgrey);

    k2settings = &_k2settings;
    masterinfo = &_masterinfo;
    /* Initialize settings */
    k2pdfopt_settings_init_from_koptcontext(k2settings, kctx);
    k2pdfopt_settings_quick_sanity_check(k2settings);
    /* Init for new source doc */
    k2pdfopt_settings_new_source_document_init(k2settings);
    /* Init master output structure */
    masterinfo_init(masterinfo, k2settings);
    wrapbmp_init(&masterinfo->wrapbmp, k2settings->dst_color);
    /* Init new source bitmap */
    bmpregion_init(&region);
    masterinfo_new_source_page_init(masterinfo, k2settings, src, srcgrey, NULL,
            &region, k2settings->src_rot, NULL, NULL, 1, -1, NULL );
    /* Set output size */
    k2pdfopt_settings_set_margins_and_devsize(k2settings,&region,masterinfo,-1.,0);
    /* Process single source page */
    bmpregion_source_page_add(&region, k2settings, masterinfo, 1, 0);
    wrapbmp_flush(masterinfo, k2settings, 0);

    if (fabs(k2settings->dst_gamma - 1.0) > .001)
        bmp_gamma_correct(&masterinfo->bmp, &masterinfo->bmp,
                k2settings->dst_gamma);

    /* copy master bitmap to context dst bitmap */
    dst = &kctx->dst;
    marbot = (int) (k2settings->dst_dpi * k2settings->dstmargins.box[1] + .5);
    marleft = (int) (k2settings->dst_dpi * k2settings->dstmargins.box[0] + .5);
    dst->bpp = masterinfo->bmp.bpp;
    dst->width = masterinfo->bmp.width;
    dst->height = masterinfo->rows > kctx->page_height ? masterinfo->rows + marbot : kctx->page_height;
    bmp_alloc(dst);
    bmp_fill(dst, 255, 255, 255);
    bw = bmp_bytewidth(&masterinfo->bmp);
    for (i = 0; i < masterinfo->rows; i++)
        memcpy(bmp_rowptr_from_top(dst, i),
                bmp_rowptr_from_top(&masterinfo->bmp, i), bw);

    kctx->page_width = kctx->dst.width;
    kctx->page_height = kctx->dst.height;
    kctx->precache = 0;

    int j;
    BOXA *rboxa = boxaCreate(masterinfo->rectmaps.n);
    BOXA *nboxa = boxaCreate(masterinfo->rectmaps.n);
    for (j = 0; j < masterinfo->rectmaps.n; j++) {
        WRECTMAP * rectmap = &masterinfo->rectmaps.wrectmap[j];
        rectmap->coords[1].x += marleft;
        BOX* rlbox = boxCreate(rectmap->coords[1].x,
                              rectmap->coords[1].y,
                              rectmap->coords[2].x,
                              rectmap->coords[2].y);
        BOX* nlbox = boxCreate(rectmap->coords[0].x*k2settings->src_dpi/rectmap->srcdpiw/kctx->zoom + kctx->bbox.x0,
                              rectmap->coords[0].y*k2settings->src_dpi/rectmap->srcdpih/kctx->zoom + kctx->bbox.y0,
                              rectmap->coords[2].x*k2settings->src_dpi/rectmap->srcdpiw/kctx->zoom,
                              rectmap->coords[2].y*k2settings->src_dpi/rectmap->srcdpih/kctx->zoom);
        boxaAddBox(rboxa, rlbox, L_INSERT);
        boxaAddBox(nboxa, nlbox, L_INSERT);
        wrectmaps_add_wrectmap(&kctx->rectmaps, rectmap);

        /*printf("rectmap:coords:\t%.1f %.1f\t%.1f %.1f\t%.1f %.1f\t%.1f %.1f\n",
                rectmap->coords[0].x, rectmap->coords[0].y,
                rectmap->coords[1].x, rectmap->coords[1].y,
                rectmap->coords[2].x, rectmap->coords[2].y,
                rectmap->srcdpiw,     rectmap->srcdpih);*/
    }
    /* 2D sort the bounding boxes of these words. */
    BOXAA *rbaa = boxaSort2d(rboxa, NULL, 3, -5, 5);
    BOXAA *nbaa = boxaSort2d(nboxa, NULL, 3, -5, 5);

    /* Flatten the boxaa, saving the boxa index for each box */
    kctx->rboxa = boxaaFlattenToBoxa(rbaa, &kctx->rnai, L_CLONE);
    kctx->nboxa = boxaaFlattenToBoxa(nbaa, &kctx->nnai, L_CLONE);

    boxaDestroy(&rboxa);
    boxaaDestroy(&rbaa);
    boxaDestroy(&nboxa);
    boxaaDestroy(&nbaa);

    bmp_free(src);
    bmp_free(srcgrey);
    bmpregion_free(&region);
    masterinfo_free(masterinfo, k2settings);
}
Exemplo n.º 9
0
static MENU_UPDATE_FUNC(mrc_dump_update_all)
{
    if (!info->can_custom_draw) return;
    info->custom_drawing = CUSTOM_DRAW_THIS_MENU;
    bmp_fill(COLOR_BLACK, 0, 0, 720, 480);

    int skip = (mrc_dump_page - 1) * (450 / font_large.height);
    int k = 0;
    int y = 0;
    int printed = 0;

    for(int pos = 0; pos < COUNT(cp_regs); pos++)
    {
        char *str = cp_regs[pos].desc;

        if(!str)
        {
            break;
        }

        k++;
        if (k <= skip)
        {
            continue;
        }

        mrc_cp = cp_regs[pos].cp;
        mrc_crn = cp_regs[pos].crn;
        mrc_op1 = cp_regs[pos].op1;
        mrc_crm = cp_regs[pos].crm;
        mrc_op2 = cp_regs[pos].op2;
        mrc_dump_process();

        printed = 1;

        if(k%2)
        {
            bmp_fill(COLOR_GRAY(10), 0, y, 720, font_large.height);
        }

        int yasm = y + font_small.height;
        bmp_printf(
            SHADOW_FONT(FONT_SMALL), 10, y,
            "%s", str
        );

        bmp_printf(
            SHADOW_FONT(FONT_MED), 10, yasm,
            "MRC p%d, %d, Rd, c%d, c%d, %d",
            mrc_cp, mrc_op1, mrc_crn, mrc_crm, mrc_op2
        );

        bmp_printf(
            SHADOW_FONT(FONT(FONT_LARGE, COLOR_YELLOW, COLOR_BLACK)),
            720 - 8*font_large.width, y,
            "%8x",
            mrc_value
        );

        y += font_large.height;

        if (y > 440)
        {
            bmp_printf(FONT(FONT_MED, COLOR_CYAN, COLOR_BLACK), 710 - 7*font_med.width, y, "more...");
            break;
        }
    }
    if (!printed)
    {
        mrc_dump_page = 1;
    }
}
Exemplo n.º 10
0
/*
** Returns 0 for success, negative number for error code.
** bpp can be 24 or 8.
**
*/
int bmpdjvu_djvufile_to_bmp(WILLUSBITMAP *bmp,char *infile,int pageno,
                            int dpi,int bpp,FILE *out)

    {
    ddjvu_context_t *ctx;
    ddjvu_document_t *doc;
    ddjvu_page_t *page;
    /* ddjvu_page_type_t type; */
    ddjvu_rect_t prect;
    ddjvu_rect_t rrect;
    ddjvu_format_style_t style;
    ddjvu_render_mode_t mode;
    ddjvu_format_t *fmt;
    int i,iw,ih,idpi,status;

    ctx=ddjvu_context_create("bmpdjvu_djvufile_to_bmp");
    if (ctx==NULL)
        {
        nprintf(out,"Cannot create djvu context.\n");
        return(-1);
        }
    doc=ddjvu_document_create_by_filename_utf8(ctx,infile,1);
    if (doc==NULL)
        {
        ddjvu_context_release(ctx);
        nprintf(out,"Cannot create djvu document context from djvu file %s.\n",
                infile);
        return(-2);
        }
    i=ddjvu_document_get_pagenum(doc);
    if (pageno<0 || pageno>i)
        {
        ddjvu_document_release(doc);
        ddjvu_context_release(ctx);
        nprintf(out,"Page number %d is out of range for djvu file %s.\n",pageno,infile);
        return(-3);
        }
    page=ddjvu_page_create_by_pageno(doc,pageno-1);
    if (page==NULL)
        {
        ddjvu_document_release(doc);
        ddjvu_context_release(ctx);
        nprintf(out,"Cannot parse page %d of djvu file %s.\n",pageno,infile);
        return(-4);
        }
    while (!ddjvu_page_decoding_done(page))
        handle(1,ctx);
    if (ddjvu_page_decoding_error(page))
        {
        ddjvu_page_release(page);
        ddjvu_document_release(doc);
        ddjvu_context_release(ctx);
        nprintf(out,"Error decoding page %d of djvu file %s.\n",pageno,infile);
        return(-5);
        }
    /* type= */ ddjvu_page_get_type(page);
    /*
    printf("type=%d\n",type);
    description=ddjvu_page_get_long_description(page);
    printf("Description='%s'\n",description);
    */
    iw = ddjvu_page_get_width(page);
    ih = ddjvu_page_get_height(page);
    idpi = ddjvu_page_get_resolution(page);
    prect.x=prect.y=0;
    bmp->width=prect.w=iw*dpi/idpi;
    bmp->height=prect.h=ih*dpi/idpi;
    bmp->bpp=(bpp==8) ? 8 : 24;
    rrect=prect;
    bmp_alloc(bmp);
    if (bmp->bpp==8)
        {
        int ii;
        for (ii=0;ii<256;ii++)
            bmp->red[ii]=bmp->blue[ii]=bmp->green[ii]=ii;
        }
    mode=DDJVU_RENDER_COLOR;
    style=bpp==8 ? DDJVU_FORMAT_GREY8 : DDJVU_FORMAT_RGB24;
    fmt=ddjvu_format_create(style,0,0);
    if (fmt==NULL)
        {
        ddjvu_page_release(page);
        ddjvu_document_release(doc);
        ddjvu_context_release(ctx);
        nprintf(out,"Error setting DJVU format for djvu file %s (page %d).\n",infile,pageno);
        return(-6);
        }
    ddjvu_format_set_row_order(fmt,1);
    status=ddjvu_page_render(page,mode,&prect,&rrect,fmt,bmp_bytewidth(bmp),(char *)bmp->data);
    /* Seems to return 0 for blank/empty page */
    if (!status) 
        bmp_fill(bmp,255,255,255);
    ddjvu_format_release(fmt);
    ddjvu_page_release(page);
    ddjvu_document_release(doc);
    ddjvu_context_release(ctx);
    /*
    if (!status)
        {
        nprintf(out,"Error rendering page %d of djvu file %s.\n",pageno,infile);
        return(-7);
        }
    */
    return(0);
    }