diff --git a/engine/asset.cpp b/engine/asset.cpp index cabc4ff..6a87884 100644 --- a/engine/asset.cpp +++ b/engine/asset.cpp @@ -100,7 +100,7 @@ std::vector Asset::list_files(std::string folder, bool is_asset, co bool Asset::open(const char* path) { - LOG("Asset::open %s", path); + //LOG("Asset::open %s", path); m_current_path = path; std::string file_path = path; #ifdef __ANDROID__ @@ -117,7 +117,7 @@ bool Asset::open(const char* path) std::string base = [bundle_path cStringUsingEncoding:1]; file_path = base + "/" + path; #endif - LOG("asset file: %s", file_path.c_str()); + //LOG("asset file: %s", file_path.c_str()); if (!(m_fp = fopen(file_path.c_str(), "rb"))) { LOG("errno = %d", errno); diff --git a/engine/canvas.cpp b/engine/canvas.cpp index b75b157..c0428c0 100644 --- a/engine/canvas.cpp +++ b/engine/canvas.cpp @@ -832,6 +832,7 @@ void ui::Canvas::export_equirectangular(std::string data_path) jpge::params params; params.m_quality = 100; bool saved = jpge::compress_image_to_jpeg_file(name, m_latlong.getWidth(), m_latlong.getHeight(), 4, latlong_data.get(), params); + inject_xmp(name); //int ret = stbi_write_png(name, m_latlong.getWidth(), m_latlong.getHeight(), 4, latlong_data.get(), m_latlong.stride()); #ifdef __IOS__ image = [UIImage imageWithContentsOfFile:[NSString stringWithUTF8String:name]]; @@ -849,6 +850,54 @@ void ui::Canvas::export_equirectangular(std::string data_path) glActiveTexture(GL_TEXTURE0); } +void ui::Canvas::inject_xmp(std::string jpg_path) +{ + static const char xmp[] = +"http://ns.adobe.com/xap/1.0/\0" R"( + + + + equirectangular + True + 0 + 0 + 0 + 0 + 0 + PanoPainter + + + +)"; + + FILE* fp = fopen(jpg_path.c_str(), "rb"); + fseek(fp, 0, SEEK_END); + long len = ftell(fp); + fseek(fp, 0, SEEK_SET); + unsigned char* jpeg_data = (unsigned char*)malloc(len); + fread(jpeg_data, len, 1, fp); + fclose(fp); + + fp = fopen(jpg_path.c_str(), "wb"); + + int i = 0; + while (i < len && !(jpeg_data[i] == 0xff && jpeg_data[i + 1] == 0xd8)) i++; + i += 2; + + unsigned char* xmp_section = (unsigned char*)malloc(sizeof(xmp) + 4); + xmp_section[0] = 0xff; + xmp_section[1] = 0xe1; + xmp_section[2] = ((int)sizeof(xmp) + 2) >> 8; + xmp_section[3] = ((int)sizeof(xmp) + 2) >> 0; + memcpy(xmp_section + 4, xmp, sizeof(xmp)); + + fwrite(jpeg_data, 1, i, fp); + fwrite(xmp_section, 1, sizeof(xmp) + 4, fp); + fwrite(jpeg_data + i, 1, len - i, fp); + fclose(fp); + +} + void ui::Canvas::export_anim(std::string data_path) { // save viewport and clear color states diff --git a/engine/canvas.h b/engine/canvas.h index 19849ba..ee21768 100644 --- a/engine/canvas.h +++ b/engine/canvas.h @@ -122,6 +122,7 @@ public: void export_anim(std::string data_path); void project_save(std::string data_path); void project_open(std::string data_path); + void inject_xmp(std::string jpg_path); ui::Image thumbnail_generate(int w, int h); ui::Image thumbnail_read(std::string data_path); void preview_generate(); diff --git a/engine/layout.cpp b/engine/layout.cpp index e2f0c63..e9bab05 100644 --- a/engine/layout.cpp +++ b/engine/layout.cpp @@ -47,7 +47,7 @@ bool LayoutManager::load(const char* path) LOG("Layout node without id"); return false; } - LOG("Parsing layout: %s", id_str); + //LOG("Parsing layout: %s", id_str); uint16_t id = const_hash(id_str); auto p = m_layouts.find(id); if (p == m_layouts.end()) diff --git a/engine/node.cpp b/engine/node.cpp index 0b1fc52..c8ea42d 100644 --- a/engine/node.cpp +++ b/engine/node.cpp @@ -747,7 +747,7 @@ void Node::parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr) void Node::load_internal(const tinyxml2::XMLElement* x_node) { m_name = x_node->Name(); - LOG("node %s", m_name.c_str()); + //LOG("node %s", m_name.c_str()); init(); diff --git a/engine/rtt.cpp b/engine/rtt.cpp index 443eed1..54f6678 100644 --- a/engine/rtt.cpp +++ b/engine/rtt.cpp @@ -25,13 +25,13 @@ void RTT::destroy() { unbindTexture(); glDeleteTextures(1, &texID); - LOG("TEX rtt destroy %d", texID) + //LOG("TEX rtt destroy %d", texID) } if (fboID) { unbindFramebuffer(); glDeleteFramebuffers(1, &fboID); - LOG("RTT DESTROY %d", fboID); + //LOG("RTT DESTROY %d", fboID); } texID = 0; fboID = 0; @@ -51,7 +51,7 @@ bool RTT::create(int width, int height, int tex/* = -1*/) if (tex == -1) { glGenTextures(1, &texID); - LOG("TEX rtt create %d", texID); + //LOG("TEX rtt create %d", texID); } else { @@ -78,7 +78,7 @@ bool RTT::create(int width, int height, int tex/* = -1*/) // Create a framebuffer object glGenFramebuffers(1, &fboID); glBindFramebuffer(GL_FRAMEBUFFER, fboID); - LOG("RTT CREATE %d - tex %d", fboID, texID); + //LOG("RTT CREATE %d - tex %d", fboID, texID); // Attach the texture to FBO color attachment point glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texID, 0); diff --git a/engine/texture.cpp b/engine/texture.cpp index e02158a..bd9c5be 100644 --- a/engine/texture.cpp +++ b/engine/texture.cpp @@ -41,7 +41,7 @@ bool Texture2D::create(int width, int height, GLint internal_format, GLint forma m_format = format; m_iformat = internal_format; glGenTextures(1, &m_tex); - LOG("TEX create %d", m_tex); + //LOG("TEX create %d", m_tex); bind(); glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, GL_UNSIGNED_BYTE, data); unbind();