本文整理汇总了C++中CXBTFFrame::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ CXBTFFrame::GetWidth方法的具体用法?C++ CXBTFFrame::GetWidth怎么用?C++ CXBTFFrame::GetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CXBTFFrame
的用法示例。
在下文中一共展示了CXBTFFrame::GetWidth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetImageWidth
uint32_t CXbtFile::GetImageWidth() const
{
CXBTFFrame frame;
if (!GetFirstFrame(frame))
return false;
return frame.GetWidth();
}
示例2: ConvertFrameToTexture
bool CTextureBundleXBT::ConvertFrameToTexture(const CStdString& name, CXBTFFrame& frame, CBaseTexture** ppTexture)
{
// found texture - allocate the necessary buffers
squish::u8 *buffer = new squish::u8[(size_t)frame.GetPackedSize()];
if (buffer == NULL)
{
CLog::Log(LOGERROR, "Out of memory loading texture: %s (need %"PRIu64" bytes)", name.c_str(), frame.GetPackedSize());
return false;
}
// load the compressed texture
if (!m_XBTFReader.Load(frame, buffer))
{
CLog::Log(LOGERROR, "Error loading texture: %s", name.c_str());
delete[] buffer;
return false;
}
// check if it's packed with lzo
if (frame.IsPacked())
{ // unpack
squish::u8 *unpacked = new squish::u8[(size_t)frame.GetUnpackedSize()];
if (unpacked == NULL)
{
CLog::Log(LOGERROR, "Out of memory unpacking texture: %s (need %"PRIu64" bytes)", name.c_str(), frame.GetUnpackedSize());
delete[] buffer;
return false;
}
lzo_uint s = (lzo_uint)frame.GetUnpackedSize();
if (lzo1x_decompress(buffer, (lzo_uint)frame.GetPackedSize(), unpacked, &s, NULL) != LZO_E_OK ||
s != frame.GetUnpackedSize())
{
CLog::Log(LOGERROR, "Error loading texture: %s: Decompression error", name.c_str());
delete[] buffer;
delete[] unpacked;
return false;
}
delete[] buffer;
buffer = unpacked;
}
// create an xbmc texture
*ppTexture = new CTexture();
(*ppTexture)->LoadFromMemory(frame.GetWidth(), frame.GetHeight(), 0, frame.GetFormat(), buffer);
delete[] buffer;
return true;
}
示例3: createBundle
int createBundle(const std::string& InputDir, const std::string& OutputFile, double maxMSE, unsigned int flags, bool dupecheck)
{
CXBTFWriter writer(OutputFile);
if (!writer.Create())
{
fprintf(stderr, "Error creating file\n");
return 1;
}
map<string,unsigned int> hashes;
vector<unsigned int> dupes;
CreateSkeletonHeader(writer, InputDir);
std::vector<CXBTFFile> files = writer.GetFiles();
dupes.resize(files.size());
if (!dupecheck)
{
for (unsigned int i=0;i<dupes.size();++i)
dupes[i] = i;
}
for (size_t i = 0; i < files.size(); i++)
{
struct MD5Context ctx;
MD5Init(&ctx);
CXBTFFile& file = files[i];
std::string fullPath = InputDir;
fullPath += file.GetPath();
std::string output = file.GetPath();
output = output.substr(0, 40);
while (output.size() < 46)
output += ' ';
DecodedFrames frames;
bool loaded = DecoderManager::LoadFile(fullPath, frames);
if (!loaded)
{
fprintf(stderr, "...unable to load image %s\n", file.GetPath().c_str());
continue;
}
printf("%s\n", output.c_str());
bool skip=false;
if (dupecheck)
{
for (unsigned int j = 0; j < frames.frameList.size(); j++)
MD5Update(&ctx,
(const uint8_t*)frames.frameList[j].rgbaImage.pixels,
frames.frameList[j].rgbaImage.height * frames.frameList[j].rgbaImage.pitch);
if (checkDupe(&ctx,hashes,dupes,i))
{
printf("**** duplicate of %s\n", files[dupes[i]].GetPath().c_str());
file.GetFrames().insert(file.GetFrames().end(),
files[dupes[i]].GetFrames().begin(),
files[dupes[i]].GetFrames().end());
skip = true;
}
}
if (!skip)
{
for (unsigned int j = 0; j < frames.frameList.size(); j++)
{
printf(" frame %4i (delay:%4i) ", j, frames.frameList[j].delay);
CXBTFFrame frame = createXBTFFrame(frames.frameList[j].rgbaImage, writer, maxMSE, flags);
frame.SetDuration(frames.frameList[j].delay);
file.GetFrames().push_back(frame);
printf("%s%c (%d,%d @ %" PRIu64 " bytes)\n", GetFormatString(frame.GetFormat()), frame.HasAlpha() ? ' ' : '*',
frame.GetWidth(), frame.GetHeight(), frame.GetUnpackedSize());
}
}
DecoderManager::FreeDecodedFrames(frames);
file.SetLoop(0);
writer.UpdateFile(file);
}
if (!writer.UpdateHeader(dupes))
{
fprintf(stderr, "Error writing header to file\n");
return 1;
}
if (!writer.Close())
{
fprintf(stderr, "Error closing file\n");
return 1;
}
return 0;
}
示例4: createBundle
int createBundle(const std::string& InputDir, const std::string& OutputFile, double maxMSE, unsigned int flags, bool dupecheck)
{
map<string,unsigned int> hashes;
vector<unsigned int> dupes;
CXBTF xbtf;
CreateSkeletonHeader(xbtf, InputDir);
dupes.resize(xbtf.GetFiles().size());
if (!dupecheck)
{
for (unsigned int i=0;i<dupes.size();++i)
dupes[i] = i;
}
CXBTFWriter writer(xbtf, OutputFile);
if (!writer.Create())
{
printf("Error creating file\n");
return 1;
}
std::vector<CXBTFFile>& files = xbtf.GetFiles();
for (size_t i = 0; i < files.size(); i++)
{
struct MD5Context ctx;
MD5Init(&ctx);
CXBTFFile& file = files[i];
std::string fullPath = InputDir;
fullPath += file.GetPath();
std::string output = file.GetPath();
output = output.substr(0, 40);
while (output.size() < 46)
output += ' ';
if (!IsGIF(fullPath.c_str()))
{
// Load the image
SDL_Surface* image = IMG_Load(fullPath.c_str());
if (!image)
{
printf("...unable to load image %s\n", file.GetPath());
continue;
}
bool skip=false;
printf("%s", output.c_str());
if (dupecheck)
{
MD5Update(&ctx,(const uint8_t*)image->pixels,image->h*image->pitch);
if (checkDupe(&ctx,hashes,dupes,i))
{
printf("**** duplicate of %s\n", files[dupes[i]].GetPath());
file.GetFrames().insert(file.GetFrames().end(),
files[dupes[i]].GetFrames().begin(), files[dupes[i]].GetFrames().end());
skip = true;
}
}
if (!skip)
{
CXBTFFrame frame = createXBTFFrame(image, writer, maxMSE, flags);
printf("%s%c (%d,%d @ %"PRIu64" bytes)\n", GetFormatString(frame.GetFormat()), frame.HasAlpha() ? ' ' : '*',
frame.GetWidth(), frame.GetHeight(), frame.GetUnpackedSize());
file.SetLoop(0);
file.GetFrames().push_back(frame);
}
SDL_FreeSurface(image);
}
else
{
int gnAG = AG_LoadGIF(fullPath.c_str(), NULL, 0);
AG_Frame* gpAG = new AG_Frame[gnAG];
AG_LoadGIF(fullPath.c_str(), gpAG, gnAG);
printf("%s\n", output.c_str());
bool skip=false;
if (dupecheck)
{
for (int j = 0; j < gnAG; j++)
MD5Update(&ctx,
(const uint8_t*)gpAG[j].surface->pixels,
gpAG[j].surface->h * gpAG[j].surface->pitch);
if (checkDupe(&ctx,hashes,dupes,i))
{
printf("**** duplicate of %s\n", files[dupes[i]].GetPath());
file.GetFrames().insert(file.GetFrames().end(),
files[dupes[i]].GetFrames().begin(), files[dupes[i]].GetFrames().end());
skip = true;
}
}
if (!skip)
{
for (int j = 0; j < gnAG; j++)
{
printf(" frame %4i ", j);
CXBTFFrame frame = createXBTFFrame(gpAG[j].surface, writer, maxMSE, flags);
//.........这里部分代码省略.........