void SaveScreenshot() { Player* py = &g_player[g_curP]; LoadedTex screenshot; screenshot.channels = 3; screenshot.sizeX = py->width; screenshot.sizeY = py->height; screenshot.data = (unsigned char*)malloc( sizeof(unsigned char) * py->width * py->height * 3 ); if(!screenshot.data) { OutOfMem(__FILE__, __LINE__); return; } memset(screenshot.data, 0, py->width * py->height * 3); glReadPixels(0, 0, py->width, py->height, GL_RGB, GL_UNSIGNED_BYTE, screenshot.data); FlipImage(&screenshot); char relative[256]; std::string datetime = FileDateTime(); sprintf(relative, "screenshots/%s.jpg", datetime.c_str()); char fullpath[MAX_PATH+1]; FullPath(relative, fullpath); g_log<<"Writing screenshot "<<fullpath<<std::endl; g_log.flush(); SaveJPEG(fullpath, &screenshot, 0.9f); //free(screenshot.data); }
static err_t Open(urlpart* p, const tchar_t* URL, int Flags) { err_t Result; const tchar_t *String, *Equal; tchar_t Value[MAXPATHFULL]; datetime_t Date = INVALID_DATETIME_T; String = tcsrchr(URL,URLPART_SEP_CHAR); if (!String) return ERR_INVALID_DATA; Clear(p); Node_SetData((node*)p,STREAM_URL,TYPE_STRING,URL); Equal = GetProtocol(URL,NULL,0,NULL); tcsncpy_s(Value,TSIZEOF(Value),Equal,String-Equal); tcsreplace(Value,TSIZEOF(Value),URLPART_SEP_ESCAPE,URLPART_SEPARATOR); Node_SetData((node*)p,URLPART_URL,TYPE_STRING,Value); while (String++ && *String) { Equal = tcschr(String,T('=')); if (Equal) { tchar_t *Sep = tcschr(Equal,T('#')); if (Sep) tcsncpy_s(Value,TSIZEOF(Value),Equal+1,Sep-Equal-1); else tcscpy_s(Value,TSIZEOF(Value),Equal+1); if (tcsncmp(String,T("ofs"),Equal-String)==0) p->Pos = StringToInt(Value,0); else if (tcsncmp(String,T("len"),Equal-String)==0) p->Length = StringToInt(Value,0); else if (tcsncmp(String,T("mime"),Equal-String)==0) Node_SetData((node*)p,URLPART_MIME,TYPE_STRING,Value); else if (tcsncmp(String,T("date"),Equal-String)==0) Date = StringToInt(Value,0); } String = tcschr(String,'#'); } if (Date!=INVALID_DATETIME_T && Date != FileDateTime(Node_Context(p),Node_GetDataStr((node*)p,URLPART_URL))) return ERR_INVALID_DATA; p->Input = GetStream(p,Node_GetDataStr((node*)p,URLPART_URL),Flags); if (!p->Input) return ERR_NOT_SUPPORTED; Stream_Blocking(p->Input,p->Blocking); Result = Stream_Open(p->Input,Node_GetDataStr((node*)p,URLPART_URL),Flags); if (Result == ERR_NONE && p->Pos!=INVALID_FILEPOS_T) // TODO: support asynchronous stream opening { if (Stream_Seek(p->Input,p->Pos,SEEK_SET)!=p->Pos) return ERR_INVALID_DATA; } return Result; }
err_t CreateUrlPart(nodecontext *Context, tchar_t *Out, size_t OutLen, const tchar_t *URL, filepos_t Offset, size_t Length, const tchar_t *Mime) { datetime_t FileDate; if (!URL || !URL[0]) return ERR_INVALID_DATA; stprintf_s(Out,OutLen,T("urlpart://%s"),URL); tcsreplace(Out,OutLen,URLPART_SEPARATOR,URLPART_SEP_ESCAPE); tcscat_s(Out,OutLen,URLPART_SEPARATOR); if (Offset > 0) stcatprintf_s(Out,OutLen,T("ofs=%d#"),(int)Offset); // TODO: support 64 bits offset if (Length > 0) stcatprintf_s(Out,OutLen,T("len=%d#"),(int)Length); if (Mime) stcatprintf_s(Out,OutLen,T("mime=%s#"),Mime); FileDate = FileDateTime(Context,URL); if (FileDate != INVALID_DATETIME_T) stcatprintf_s(Out,OutLen,T("date=%d#"),(int)FileDate); return ERR_NONE; }