代码拉取完成,页面将自动刷新
我尝试在项目中加入能查看点云深度图的功能,点云深度图本质是jpg图只是需要做变换之后才能正常显示,我尝试仿照PhotoInfoGIF写了自己的PhotoInfo,但是好像不行,是找到CFileDataSource的底层是在StdFile.cpp中打开文件的,尝试添加了如下的代码也不行,我使用转换过的图片是能打开的
StdFile.cpp
UINT StdFile::Read(void* buffer, UINT count)
{
ASSERT(file_ != 0);
if (count == 0)
return 0;
ASSERT(AfxIsValidAddress(buffer, count));
if (buffer == 0)
AfxThrowInvalidArgException();
fseek(file_, 0L, SEEK_END);
int jpegSize = ftell(file_);
auto m_jpegSize = jpegSize;
buffer = (unsigned char*)malloc(m_jpegSize);
char* jpegBuf = (char*)buffer;
fseek(file_, 0L, SEEK_SET);
UINT read= static_cast<UINT>(fread(buffer, sizeof(BYTE), count, file_));
//简单变换
for (int i = 0; i < count; i++)
{
jpegBuf[i] -= dept[i % 7];
}
buffer =(void*) jpegBuf;
if (read == 0 && !feof(file_))
AfxThrowFileException(CFileException::genericException, _doserrno, FileName());
if (ferror(file_))
{
Afx_clearerr_s(file_);
AfxThrowFileException(CFileException::genericException, _doserrno, FileName());
}
return read;
}
PhotoInfoDPT.cpp
ImageStat PhotoInfoDPT::CreateThumbnail(Dib& bmp, DecoderProgress* progress) const
{
try
{
if (!jpeg_thumb_.IsEmpty())
return jpeg_thumb_.GetDib(bmp);
//AutoPtr<JPEGDataSource> file = new CFileDataSource(path_.c_str(), jpeg_offset_);
FILE* file;
errno_t err;
std::wstring ws(path_.c_str());
std::string str(ws.begin(), ws.end());
if ((err = fopen_s(&file, str.c_str(), "rb")) != 0)
{
fprintf(stderr, "can't open %s\n", path_);
}
fseek(file, 0L, SEEK_END);
int jpegSize = ftell(file);
auto m_jpegSize = jpegSize;
auto m_jpegBuf = (unsigned char*)malloc(m_jpegSize);
char* jpegBuf = (char*)m_jpegBuf;
fseek(file, 0L, SEEK_SET);
fread(jpegBuf, m_jpegSize, 1, file);
//fclose(file);
static char dept[] = "DPT";
//简单变换
for (int i = 0; i < jpegSize; i++)
{
jpegBuf[i] -= g_passwd[i % 3];
}
FILE* fp=file;
fp = fopen("file.jpg", "w+b");
fwrite(jpegBuf, jpegSize, 1, fp);;
#pragma endregion
JPEGDecoder decoder(file, JDEC_INTEGER_LOQ);
//fclose(fp);
decoder.SetFast(true, true);
decoder.SetProgressClient(progress);
return decoder.DecodeImg(bmp, GetThumbnailSize(), true);
}
catch (...) // for now (TODO--failure codes)
{
ASSERT(false);
}
return IS_READ_ERROR;
}