add xmp injection and disable some log messages

This commit is contained in:
2017-09-27 23:02:39 +01:00
parent 90ec0b6f7b
commit 2c0007c3c1
7 changed files with 59 additions and 9 deletions

View File

@@ -100,7 +100,7 @@ std::vector<std::string> 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);

View File

@@ -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"(<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" xmptk="SAMSUNG 360CAM">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="" xmlns:GPano="http://ns.google.com/photos/1.0/panorama/">
<GPano:ProjectionType>equirectangular</GPano:ProjectionType>
<GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>
<GPano:CroppedAreaLeftPixels>0</GPano:CroppedAreaLeftPixels>
<GPano:CroppedAreaTopPixels>0</GPano:CroppedAreaTopPixels>
<GPano:PoseHeadingDegrees>0</GPano:PoseHeadingDegrees>
<GPano:PosePitchDegrees>0</GPano:PosePitchDegrees>
<GPano:PoseRollDegrees>0</GPano:PoseRollDegrees>
<GPano:StitchingSoftware>PanoPainter</GPano:StitchingSoftware>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="r"?>)";
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

View File

@@ -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();

View File

@@ -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())

View File

@@ -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();

View File

@@ -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);

View File

@@ -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();