Пример #1
0
// # tizen bridge
void iotjs_tizen_func(const char* command, const char* message, void* handle) {
  DDDLOG("%s, cmd: %s, msg: %s", __func__, command, message);

  if (strncmp(command, "getResPath", strlen("getResPath")) == 0) {
    char* app_res_path = app_get_resource_path();
    iotjs_bridge_set_msg(handle, app_res_path);
    if (app_res_path != NULL) {
      free(app_res_path);
    }
  } else if (strncmp(command, "getDataPath", strlen("getDataPath")) == 0) {
    char* app_data_path = app_get_data_path();
    iotjs_bridge_set_msg(handle, app_data_path);
    if (app_data_path != NULL) {
      free(app_data_path);
    }
  } else if (strncmp(command, "launchAppControl", strlen("launchAppControl")) ==
             0) {
    iotjs_error_t err = tizen_send_launch_request(message, handle);
    if (err == IOTJS_ERROR_NONE) {
      iotjs_bridge_set_msg(handle, "OK");
    }

  } else {
    iotjs_bridge_set_err(handle, "Can't find command");
  }
}
static void
app_get_resource(const char *edj_file_in, char *edj_path_out, int edj_path_max)
{
	char *res_path = app_get_resource_path();
	if (res_path) {
		snprintf(edj_path_out, edj_path_max, "%s%s", res_path, edj_file_in);
		free(res_path);
	}
}
Пример #3
0
unsigned int read_texture(Evas_Object *parent, const char *filename) {

    unsigned int gltex_object;
    int w, h;
    int surface_w, surface_h;
    evas_object_geometry_get(parent, NULL, NULL, &surface_w, &surface_h);

    Evas_Object* inline_buffer = elm_win_add(parent,"Img Read",ELM_WIN_INLINED_IMAGE);
    evas_object_move(inline_buffer, 0, 0);
    evas_object_resize(inline_buffer, surface_w, surface_h);
    evas_object_show(inline_buffer);

    Evas* canvas = evas_object_evas_get(inline_buffer);
    Evas_Object* image = evas_object_image_add(canvas);

    char path[200];
    sprintf(path, "%s%s", app_get_resource_path(), filename);
    evas_object_image_file_set(image, path, NULL);
    evas_object_image_size_get(image, &w, &h);
    evas_object_image_fill_set(image, 0, 0, w, h);
    evas_object_image_filled_set(image, EINA_TRUE);
    evas_object_resize(image, w, h);
    evas_object_show(image);

    elm_win_render(inline_buffer);

    GLubyte* pixels;
    pixels = (GLubyte*) evas_object_image_data_get(image, EINA_FALSE);

    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    glGenTextures(1, &gltex_object);

    glBindTexture(GL_TEXTURE_2D, gltex_object);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, w, h, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels);

    glGenerateMipmap(GL_TEXTURE_2D);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

    glBindTexture(GL_TEXTURE_2D, 0);

    evas_object_del(inline_buffer);

    return gltex_object;

}
Пример #4
0
std::string FileLoader::ReadTxtFile(const std::string &filename) const
{

    std::string path = app_get_resource_path() + filename;

    std::ifstream in(path, std::ios::in | std::ios::binary);

    std::string msg = "Failed to open file " + path;
    ASSERT(in.is_open() && in.good(), msg.c_str());

    std::string ret;
    in.seekg(0, std::ios::end);         // Set get position to end
    ret.resize(in.tellg());            // Resize string to support enough bytes
    in.seekg(0, std::ios::beg);         // Set get position to beginning
    in.read(&ret.at(0), ret.size());     // Read file to string
    in.close();

    return ret;

}
Пример #5
0
void FileLoader::ReadTexture(const char *filename, TexData &out) const
{

    Evas_Object * parent = SampleLauncher::GetInstance()->GetParent();

    int w, h;
    int surface_w, surface_h;
    evas_object_geometry_get(parent, NULL, NULL, &surface_w, &surface_h);

    Evas_Object * inline_buffer = elm_win_add(parent, "Img Read", ELM_WIN_INLINED_IMAGE);
    evas_object_move(inline_buffer, 0, 0);
    evas_object_resize(inline_buffer, surface_w, surface_h);
    evas_object_show(inline_buffer);

    Evas *canvas = evas_object_evas_get(inline_buffer);
    Evas_Object * image = evas_object_image_add(canvas);

    char path[200];
    sprintf(path, "%s%s", app_get_resource_path(), filename);
    evas_object_image_file_set(image, path, NULL);
    evas_object_image_size_get(image, &w, &h);
    evas_object_image_fill_set(image, 0, 0, w, h);
    evas_object_image_filled_set(image, EINA_TRUE);
    evas_object_resize(image, w, h);
    evas_object_show(image);

    elm_win_render(inline_buffer);

    GLubyte *pixels;
    pixels = static_cast<GLubyte *>(evas_object_image_data_get(image, EINA_FALSE));

    out.SetData(w * h, pixels, w, h, GL_BGRA_EXT);

    evas_object_del(inline_buffer);

}