void print_sift_scalespace_rgb(const struct sift_scalespace* scalespace, const char* basename)
{
    char name[FILENAME_MAX];
    int wALL = scalespace->octaves[0]->w;
    int hALL = scalespace->octaves[0]->h;
    _myfloat* imtemp = xmalloc(wALL*hALL*sizeof(_myfloat));
    _myfloat* imrgb = xmalloc(3*wALL*hALL*sizeof(_myfloat));

    int nOct = scalespace->nOct;
    for(int o = 0; o < nOct; o++){
        const struct octa* octave = scalespace->octaves[o];
        int nSca = octave->nSca;
        int w = octave->w;
        int h = octave->h;
        for(int s = 1; s < nSca-1; s++){
            const _myfloat* image = &octave->imStack[s*w*h];
            nearestneighbor_interp(image,w,h,imtemp,wALL,hALL);
            gray2Msh2rgb(imtemp, imrgb, wALL, hALL);
            sprintf(name,"%s_o%03i_s%03i.png",basename,o,s);
            printrgb(imrgb, wALL,hALL, name);
            gray2Msh2rgb(image, imrgb, w, h);
            sprintf(name,"%s_o%03i_s%03i.png",basename,o,s);
            printrgb(imrgb, w, h, name);
            // TEMP text files too
            //sprintf(name,"%s_o%03i_s%03i.txt",basename,o,s);
            //printImage_in_txtfile(image, w, h, name);
            // END TEMP text files too
        }
    }
    xfree(imrgb);
    xfree(imtemp);
}
示例#2
0
文件: notify.c 项目: Ningrui-Li/ckb
void getinfo(usbdevice* kb, usbmode* mode, const char* setting){
    if(!strcmp(setting, ":hello")){
        if(kb && mode)
            return;
        nrprintf("hello\n");
        return;
    } else if(!strcmp(setting, ":fps")){
        if(kb && mode)
            return;
        nrprintf("fps %d\n", fps);
        return;
    } else if(!strcmp(setting, ":layout")){
        if(kb && mode)
            nprintf(kb, 0, 0, "layout %s\n", kb->profile.keymap == keymap_uk ? "uk" : "us");
        else
            nrprintf("layout %s\n", keymap_system == keymap_uk ? "uk" : "us");
        return;
    } else if(!kb || !mode)
        // Only FPS and layout can be printed without an active mode
        return;

    usbprofile* profile = &kb->profile;
    if(!strcmp(setting, ":mode")){
        // Get the current mode number
        nprintf(kb, 0, mode, "switch\n");
        return;
    } else if(!strcmp(setting, ":rgb")){
        // Get the current RGB settings
        char* rgb = printrgb(&mode->light, profile->keymap);
        nprintf(kb, 0, mode, "rgb %s\n", rgb);
        free(rgb);
        return;
    } else if(!strcmp(setting, ":hwrgb")){
        // Get the current hardware RGB settings
        unsigned index = INDEX_OF(mode, profile->mode);
        // Make sure the mode number is valid
        switch(kb->model){
        case 95:
            if(index >= HWMODE_K95)
                return;
            break;
        case 70:
            if(index >= HWMODE_K70)
                return;
            break;
        default:
            return;
        }
        // Get the mode from the hardware store
        char* rgb = printrgb(profile->hw->light + index, profile->keymap);
        nprintf(kb, 0, mode, "hwrgb %s\n", rgb);
        free(rgb);
        return;
    }
}
void print_sift_scalespace_rgb_nointerp(const struct sift_scalespace* scalespace, const char* basename)
{
    char name[FILENAME_MAX];
    int nOct = scalespace->nOct;
    for(int o = 0; o < nOct; o++){
        struct octa* octave = scalespace->octaves[o];
        int nSca   = octave->nSca;
        int w  = octave->w;
        int h = octave->h;

        for(int s = 1; s < nSca - 1; s++){
            const _myfloat* image = &octave->imStack[s*w*h];
            _myfloat* imrgb = xmalloc(3*w*h*sizeof(_myfloat));
            for(int i = 0; i < 3*w*h; i++){
                imrgb[i] = 0.0;
            }
            gray2Msh2rgb(image, imrgb, w, h);
            sprintf(name,"%s_o%03i_s%03i.png",basename,o,s);
            printrgb(imrgb, w,h, name);
            xfree(imrgb);
        }
    }
}
示例#4
0
文件: notify.c 项目: akosipc/ckb
static void _cmd_get(usbdevice* kb, usbmode* mode, int nnumber, const char* setting){
    usbprofile* profile = kb->profile;
    if(!strcmp(setting, ":mode")){
        // Get the current mode number
        nprintf(kb, nnumber, mode, "switch\n");
        return;
    } else if(!strcmp(setting, ":rgb")){
        // Get the current RGB settings
        char* rgb = printrgb(&mode->light, kb);
        nprintf(kb, nnumber, mode, "rgb %s\n", rgb);
        free(rgb);
        return;
    } else if(!strcmp(setting, ":hwrgb")){
        // Get the current hardware RGB settings
        HW_STANDARD;
        char* rgb = printrgb(kb->hw->light + index, kb);
        nprintf(kb, nnumber, mode, "hwrgb %s\n", rgb);
        free(rgb);
        return;
    } else if(!strcmp(setting, ":profilename")){
        // Get the current profile name
        char* name = getprofilename(profile);
        nprintf(kb, nnumber, 0, "profilename %s\n", name[0] ? name : "Unnamed");
        free(name);
    } else if(!strcmp(setting, ":name")){
        // Get the current mode name
        char* name = getmodename(mode);
        nprintf(kb, nnumber, mode, "name %s\n", name[0] ? name : "Unnamed");
        free(name);
    } else if(!strcmp(setting, ":hwprofilename")){
        // Get the current hardware profile name
        if(!kb->hw)
            return;
        char* name = gethwprofilename(kb->hw);
        nprintf(kb, nnumber, 0, "hwprofilename %s\n", name[0] ? name : "Unnamed");
        free(name);
    } else if(!strcmp(setting, ":hwname")){
        // Get the current hardware mode name
        HW_STANDARD;
        char* name = gethwmodename(kb->hw, index);
        nprintf(kb, nnumber, mode, "hwname %s\n", name[0] ? name : "Unnamed");
        free(name);
    } else if(!strcmp(setting, ":profileid")){
        // Get the current profile ID
        char* guid = getid(&profile->id);
        int modified;
        memcpy(&modified, &profile->id.modified, sizeof(modified));
        nprintf(kb, nnumber, 0, "profileid %s %x\n", guid, modified);
        free(guid);
    } else if(!strcmp(setting, ":id")){
        // Get the current mode ID
        char* guid = getid(&mode->id);
        int modified;
        memcpy(&modified, &mode->id.modified, sizeof(modified));
        nprintf(kb, nnumber, mode, "id %s %x\n", guid, modified);
        free(guid);
    } else if(!strcmp(setting, ":hwprofileid")){
        // Get the current hardware profile ID
        if(!kb->hw)
            return;
        char* guid = getid(&kb->hw->id[0]);
        int modified;
        memcpy(&modified, &kb->hw->id[0].modified, sizeof(modified));
        nprintf(kb, nnumber, 0, "hwprofileid %s %x\n", guid, modified);
        free(guid);
    } else if(!strcmp(setting, ":hwid")){
        // Get the current hardware mode ID
        HW_STANDARD;
        char* guid = getid(&kb->hw->id[index + 1]);
        int modified;
        memcpy(&modified, &kb->hw->id[index + 1].modified, sizeof(modified));
        nprintf(kb, nnumber, mode, "hwid %s %x\n", guid, modified);
        free(guid);
    } else if(!strcmp(setting, ":keys")){
        // Get the current state of all keys
        for(int i = 0; i < N_KEYS_INPUT; i++){
            if(!keymap[i].name)
                continue;
            int byte = i / 8, bit = 1 << (i & 7);
            uchar state = kb->input.keys[byte] & bit;
            nprintkey(kb, nnumber, i, state);
        }
    } else if(!strcmp(setting, ":i")){
        // Get the current state of all indicator LEDs
        nprintind(kb, nnumber, I_NUM, kb->ileds & I_NUM);
        nprintind(kb, nnumber, I_CAPS, kb->ileds & I_CAPS);
        nprintind(kb, nnumber, I_SCROLL, kb->ileds & I_SCROLL);
    } else if(!strcmp(setting, ":dpi")){
        // Get the current DPI levels
        char* dpi = printdpi(&mode->dpi, kb);
        nprintf(kb, nnumber, mode, "dpi %s\n", dpi);
        free(dpi);
        return;
    } else if(!strcmp(setting, ":hwdpi")){
        // Get the current hardware DPI levels
        HW_STANDARD;
        char* dpi = printdpi(kb->hw->dpi + index, kb);
        nprintf(kb, nnumber, mode, "hwdpi %s\n", dpi);
        free(dpi);
        return;
    } else if(!strcmp(setting, ":dpisel")){
        // Get the currently-selected DPI
        nprintf(kb, nnumber, mode, "dpisel %d\n", mode->dpi.current);
    } else if(!strcmp(setting, ":hwdpisel")){
        // Get the currently-selected hardware DPI
        HW_STANDARD;
        nprintf(kb, nnumber, mode, "hwdpisel %d\n", kb->hw->dpi[index].current);
    } else if(!strcmp(setting, ":lift")){
        // Get the mouse lift height
        nprintf(kb, nnumber, mode, "lift %d\n", mode->dpi.lift);
    } else if(!strcmp(setting, ":hwlift")){
        // Get the hardware lift height
        HW_STANDARD;
        nprintf(kb, nnumber, mode, "hwlift %d\n", kb->hw->dpi[index].lift);
    } else if(!strcmp(setting, ":snap")){
        // Get the angle snap status
        nprintf(kb, nnumber, mode, "snap %s\n", mode->dpi.snap ? "on" : "off");
    } else if(!strcmp(setting, ":hwsnap")){
        // Get the hardware angle snap status
        HW_STANDARD;
        nprintf(kb, nnumber, mode, "hwsnap %s\n", kb->hw->dpi[index].snap ? "on" : "off");
    }
}
示例#5
0
文件: notify.c 项目: julianliaw/ckb
void getinfo(usbdevice* kb, usbmode* mode, int nnumber, const char* setting){
    if(!strcmp(setting, ":hello")){
        if(kb && mode)
            return;
        nrprintf(nnumber, "hello\n");
        return;
    } else if(!strcmp(setting, ":fps")){
        if(kb && mode)
            return;
        nrprintf(nnumber, "fps %d\n", fps);
        return;
    } else if(!strcmp(setting, ":layout")){
        if(kb && mode)
            nprintf(kb, nnumber, 0, "layout %s\n", getmapname(kb->profile.keymap));
        else
            nrprintf(nnumber, "layout %s\n", getmapname(keymap_system));
        return;
    } else if(!kb || !mode)
        // Only FPS and layout can be printed without an active mode
        return;

    usbprofile* profile = &kb->profile;
    if(!strcmp(setting, ":mode")){
        // Get the current mode number
        nprintf(kb, nnumber, mode, "switch\n");
        return;
    } else if(!strcmp(setting, ":rgb")){
        // Get the current RGB settings
        char* rgb = printrgb(&mode->light, profile->keymap);
        nprintf(kb, nnumber, mode, "rgb %s\n", rgb);
        free(rgb);
        return;
    } else if(!strcmp(setting, ":rgbon")){
        // Get the current RGB status
        if(mode->light.enabled)
            nprintf(kb, nnumber, mode, "rgb on\n");
        else
            nprintf(kb, nnumber, mode, "rgb off\n");
        return;
    } else if(!strcmp(setting, ":hwrgb")){
        // Get the current hardware RGB settings
        if(!kb->hw)
            return;
        unsigned index = INDEX_OF(mode, profile->mode);
        // Make sure the mode number is valid
        HWMODE_OR_RETURN(kb, index);
        // Get the mode from the hardware store
        char* rgb = printrgb(kb->hw->light + index, profile->keymap);
        nprintf(kb, nnumber, mode, "hwrgb %s\n", rgb);
        free(rgb);
        return;
    } else if(!strcmp(setting, ":profilename")){
        // Get the current profile name
        char* name = getprofilename(profile);
        nprintf(kb, nnumber, 0, "profilename %s\n", name[0] ? name : "Unnamed");
        free(name);
    } else if(!strcmp(setting, ":name")){
        // Get the current mode name
        char* name = getmodename(mode);
        nprintf(kb, nnumber, mode, "name %s\n", name[0] ? name : "Unnamed");
        free(name);
    } else if(!strcmp(setting, ":hwprofilename")){
        // Get the current hardware profile name
        if(!kb->hw)
            return;
        char* name = gethwprofilename(kb->hw);
        nprintf(kb, nnumber, 0, "hwprofilename %s\n", name[0] ? name : "Unnamed");
        free(name);
    } else if(!strcmp(setting, ":hwname")){
        // Get the current hardware mode name
        if(!kb->hw)
            return;
        unsigned index = INDEX_OF(mode, profile->mode);
        HWMODE_OR_RETURN(kb, index);
        char* name = gethwmodename(kb->hw, index);
        nprintf(kb, nnumber, mode, "hwname %s\n", name[0] ? name : "Unnamed");
        free(name);
    } else if(!strcmp(setting, ":profileid")){
        // Get the current profile ID
        char* guid = getid(&profile->id);
        int modified;
        memcpy(&modified, &profile->id.modified, sizeof(modified));
        nprintf(kb, nnumber, 0, "profileid %s %x\n", guid, modified);
        free(guid);
    } else if(!strcmp(setting, ":id")){
        // Get the current mode ID
        char* guid = getid(&mode->id);
        int modified;
        memcpy(&modified, &mode->id.modified, sizeof(modified));
        nprintf(kb, nnumber, mode, "id %s %x\n", guid, modified);
        free(guid);
    } else if(!strcmp(setting, ":hwprofileid")){
        // Get the current hardware profile ID
        if(!kb->hw)
            return;
        char* guid = getid(&kb->hw->id[0]);
        int modified;
        memcpy(&modified, &kb->hw->id[0].modified, sizeof(modified));
        nprintf(kb, nnumber, 0, "hwprofileid %s %x\n", guid, modified);
        free(guid);
    } else if(!strcmp(setting, ":hwid")){
        // Get the current hardware mode ID
        if(!kb->hw)
            return;
        unsigned index = INDEX_OF(mode, profile->mode);
        HWMODE_OR_RETURN(kb, index);
        char* guid = getid(&kb->hw->id[index + 1]);
        int modified;
        memcpy(&modified, &kb->hw->id[index + 1].modified, sizeof(modified));
        nprintf(kb, nnumber, mode, "hwid %s %x\n", guid, modified);
        free(guid);
    }
}