25 Star 121 Fork 25

dream7180 / Shutter

 / 详情

请问该如何编写新的输入格式?

待办的
创建于  
2023-08-18 15:46

我尝试在项目中加入能查看点云深度图的功能,点云深度图本质是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;
}

评论 (0)

x1290148 创建了任务

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(1)
5292106 x1290148 1614941150
C
1
https://gitee.com/dream7180/Shutter.git
git@gitee.com:dream7180/Shutter.git
dream7180
Shutter
Shutter

搜索帮助

53164aa7 5694891 3bd8fe86 5694891