Beispiel #1
0
void csImgGoogle::sendImgURIToClient(int _width, int _height, const QUrl & url )
{
    // add with and hight and make a jason message
    char *out;
    cJSON *json_send;
    json_send=cJSON_CreateObject();
    cJSON_AddStringToObject(json_send,"CMD",     "CREATE");
    cJSON_AddStringToObject(json_send,"TYPE",    "Image");
    cJSON_AddNumberToObject(json_send,"OID", -1);
    cJSON_AddStringToObject(json_send,"URI",     url.toString().toStdString().c_str());
    cJSON_AddNumberToObject(json_send,"WIDTH",   _width);
    cJSON_AddNumberToObject(json_send,"HEIGHT",  _height);


    float pos[2];
    pos[0]  = 0.0f;
    pos[1]  = 0.0f;

    cJSON_AddItemToObject(json_send,"POS", cJSON_CreateFloatArray(pos,2));
    pos[0]  = 1.0f;
    pos[1]  = 1.0f;
    cJSON_AddItemToObject(json_send,"SCALE", cJSON_CreateFloatArray(pos,2));

    out=cJSON_PrintUnformatted(json_send);
    cJSON_Delete(json_send);

    pte_Url->setPlainText(QString(out));
    sm->sendData((char *)out);
    free(out);
}
Beispiel #2
0
void csImgGoogle::cs_loadImages()
{
    QStringList fl;
    QFileDialog	filedialog(this);
    filedialog.setDirectory(getenv("HOME"));
    QStringList filters;
    filters << "Image files (*.png *.xpm *.jpg *.tif *.gif)"
            << "Any files (*)";
    filedialog.setNameFilters(filters);
    filedialog.setAcceptMode ( QFileDialog::AcceptOpen );
    filedialog.setFileMode(QFileDialog::ExistingFiles);
    filedialog.setWindowTitle ( QString("Open Image Files") );
    if(filedialog.exec())
    {
        fl  = filedialog.selectedFiles();
        for (int i = 0; i < fl.size(); ++i)
        {
            QPixmap pix(fl.at(i));
            //printf("W: %d H: %d File: %s\n",pix.width(),pix.height(),fl.at(i).toStdString().c_str());
            if(connected)
            {
                char *out;
                cJSON *json_send;
                json_send=cJSON_CreateObject();
                cJSON_AddStringToObject(json_send,"CMD",     "CREATE");
                cJSON_AddStringToObject(json_send,"TYPE",    "Image");
                cJSON_AddNumberToObject(json_send,"OID", -1);
                cJSON_AddStringToObject(json_send,"URI",     fl.at(i).toStdString().c_str());
                cJSON_AddNumberToObject(json_send,"WIDTH",   pix.width());
                cJSON_AddNumberToObject(json_send,"HEIGHT",  pix.height());


                float pos[2];
                pos[0]  = 0.0f;
                pos[1]  = 0.0f;
                cJSON_AddItemToObject(json_send,"POS", cJSON_CreateFloatArray(pos,2));

                pos[0]  = 1.0f;
                pos[1]  = 1.0f;
                cJSON_AddItemToObject(json_send,"SCALE", cJSON_CreateFloatArray(pos,2));

                out=cJSON_PrintUnformatted(json_send);
                cJSON_Delete(json_send);

                pte_Url->setPlainText(QString(out));
                sm->sendData((char *)out);
                free(out);
            }
        }
    }
}
Beispiel #3
0
void cJSONExt_AddFloatArrayToObject(cJSON* object, const char* name, float* vars, int numinarray)
{
    cJSON* jsonarray = cJSON_CreateFloatArray( vars, numinarray );
    cJSON_AddItemToObject( object, name, jsonarray );
}