本文整理汇总了C++中VideoBuffer::Resize方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoBuffer::Resize方法的具体用法?C++ VideoBuffer::Resize怎么用?C++ VideoBuffer::Resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VideoBuffer
的用法示例。
在下文中一共展示了VideoBuffer::Resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Process
RequestBroker::ProcessResponse ThumbRenderRequest::Process(RequestBroker & rb)
{
VideoBuffer * thumbnail = SaveRenderer::Ref().Render(Save, Decorations, Fire);
delete Save;
Save = NULL;
if(thumbnail)
{
thumbnail->Resize(Width, Height, true);
ResultObject = (void*)thumbnail;
rb.requestComplete((Request*)this);
return RequestBroker::Finished;
}
else
{
return RequestBroker::Failed;
}
return RequestBroker::Failed;
}
示例2: main
int main(int argc, char *argv[])
{
ui::Engine * engine;
std::string outputPrefix, inputFilename;
std::vector<char> inputFile;
std::string ppmFilename, ptiFilename, ptiSmallFilename, pngFilename, pngSmallFilename;
std::vector<char> ppmFile, ptiFile, ptiSmallFile, pngFile, pngSmallFile;
inputFilename = std::string(argv[1]);
outputPrefix = std::string(argv[2]);
ppmFilename = outputPrefix+".ppm";
ptiFilename = outputPrefix+".pti";
ptiSmallFilename = outputPrefix+"-small.pti";
pngFilename = outputPrefix+".png";
pngSmallFilename = outputPrefix+"-small.png";
readFile(inputFilename, inputFile);
ui::Engine::Ref().g = new Graphics();
engine = &ui::Engine::Ref();
engine->Begin(WINDOWW, WINDOWH);
GameSave * gameSave = NULL;
try
{
gameSave = new GameSave(inputFile);
}
catch (ParseException e)
{
//Render the save again later or something? I don't know
if (e.what() == "Save from newer version")
throw e;
}
Simulation * sim = new Simulation();
Renderer * ren = new Renderer(ui::Engine::Ref().g, sim);
if (gameSave)
{
sim->Load(gameSave);
//Render save
ren->decorations_enable = true;
ren->blackDecorations = true;
int frame = 15;
while(frame)
{
frame--;
ren->render_parts();
ren->render_fire();
ren->clearScreen(1.0f);
}
}
else
{
int w = Graphics::textwidth("Save file invalid")+16, x = (XRES-w)/2, y = (YRES-24)/2;
ren->drawrect(x, y, w, 24, 192, 192, 192, 255);
ren->drawtext(x+8, y+8, "Save file invalid", 192, 192, 240, 255);
}
ren->RenderBegin();
ren->RenderEnd();
VideoBuffer screenBuffer = ren->DumpFrame();
//ppmFile = format::VideoBufferToPPM(screenBuffer);
ptiFile = format::VideoBufferToPTI(screenBuffer);
pngFile = format::VideoBufferToPNG(screenBuffer);
screenBuffer.Resize(1.0f/3.0f, true);
ptiSmallFile = format::VideoBufferToPTI(screenBuffer);
pngSmallFile = format::VideoBufferToPNG(screenBuffer);
//writeFile(ppmFilename, ppmFile);
writeFile(ptiFilename, ptiFile);
writeFile(ptiSmallFilename, ptiSmallFile);
writeFile(pngFilename, pngFile);
writeFile(pngSmallFilename, pngSmallFile);
}
示例3: Process
//.........这里部分代码省略.........
{
if(http_async_req_status(HTTPContext))
{
pixel * imageData;
char * data;
int status, data_size, imgw, imgh;
data = http_async_req_stop(HTTPContext, &status, &data_size);
if (status == 200 && data)
{
imageData = Graphics::ptif_unpack(data, data_size, &imgw, &imgh);
free(data);
if(imageData)
{
//Success!
image = new VideoBuffer(imageData, imgw, imgh);
free(imageData);
}
else
{
//Error thumbnail
image = new VideoBuffer(32, 32);
image->SetCharacter(14, 14, 'x', 255, 255, 255, 255);
}
if(rb.imageCache.size() >= THUMB_CACHE_SIZE)
{
//Remove unnecessary from thumbnail cache
delete rb.imageCache.front().second;
rb.imageCache.pop_front();
}
rb.imageCache.push_back(std::pair<std::string, VideoBuffer*>(URL, image));
}
else
{
#ifdef DEBUG
std::cout << typeid(*this).name() << " Request for " << URL << " failed with status " << status << std::endl;
#endif
free(data);
return RequestBroker::Failed;
}
}
}
else
{
//Check for ongoing requests
for(std::vector<Request*>::iterator iter = rb.activeRequests.begin(), end = rb.activeRequests.end(); iter != end; ++iter)
{
if((*iter)->Type != Request::Image)
continue;
ImageRequest * otherReq = (ImageRequest*)(*iter);
if(otherReq->URL == URL && otherReq != this)
{
#ifdef DEBUG
std::cout << typeid(*this).name() << " Request for " << URL << " found, appending." << std::endl;
#endif
//Add the current listener to the item already being requested
(*iter)->Children.push_back(this);
return RequestBroker::Duplicate;
}
}
//If it's not already being requested, request it
#ifdef DEBUG
std::cout << typeid(*this).name() << " Creating new request for " << URL << std::endl;
#endif
HTTPContext = http_async_req_start(NULL, (char *)URL.c_str(), NULL, 0, 0);
RequestTime = time(NULL);
}
}
if(image)
{
//Create a copy, to seperate from the cache
std::vector<Request *> children(Children.begin(), Children.end());
Children.clear();
VideoBuffer * myVB = new VideoBuffer(*image);
myVB->Resize(Width, Height, true);
ResultObject = (void*)myVB;
rb.requestComplete(this);
for(std::vector<Request*>::iterator childIter = children.begin(), childEnd = children.end(); childIter != childEnd; ++childIter)
{
if((*childIter)->Type == Request::Image)
{
ImageRequest * childReq = (ImageRequest*)*childIter;
VideoBuffer * tempImage = new VideoBuffer(*image);
tempImage->Resize(childReq->Width, childReq->Height, true);
childReq->ResultObject = (void*)tempImage;
rb.requestComplete(*childIter);
}
}
return RequestBroker::Finished;
}
return RequestBroker::OK;
}