本文整理汇总了C++中Bitmap::Load方法的典型用法代码示例。如果您正苦于以下问题:C++ Bitmap::Load方法的具体用法?C++ Bitmap::Load怎么用?C++ Bitmap::Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitmap
的用法示例。
在下文中一共展示了Bitmap::Load方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Error
////////////////////////////////////////////////////////////////////////////////
// A helper function for loading an Allegro dat file where bitmaps are
// supposed to be stored.
MAS::Error MAS::Skin::LoadData(ALLEGRO_PATH *dir, ALLEGRO_CONFIG *config) {
if (!dir || !al_is_path_present(dir) || !al_get_path_filename(dir)) {
return Error(Error::SKIN_DAT);
}
// load the datafile
int i;
char tmp[256];
const char *str;
// Look for each bitmap inside and load it if it exists
for (i=0; i<nBitmaps; i++) {
al_set_path_filename(dir, bitmapName[i]);
al_set_path_extension(dir, ".png");
const char *fullPath = al_path_cstr(dir, ALLEGRO_NATIVE_PATH_SEP);
Bitmap bmp;
if (bmp.Load(fullPath, Bitmap::MEMORY) == Error::NONE) {
bmpList[i]->Set(bmp, true, MAS::Settings::useVideoMemory ? Bitmap::VIDEO : Bitmap::MEMORY);
snprintf(tmp, 256, "%s_TCKX", bitmapName[i]);
bmpList[i]->ThickX((str = al_get_config_value(config, "TILING", tmp)) ? strtol(str, NULL, 10) : -1);
snprintf(tmp, 256, "%s_TCKY", bitmapName[i]);
bmpList[i]->ThickY((str = al_get_config_value(config, "TILING", tmp)) ? strtol(str, NULL, 10) : -1);
}
}
al_set_path_filename(dir, "");
return Error(Error::NONE);
}
示例2: Load
void Texture::Load(std::string a)
{
name = a;
Bitmap* b = new Bitmap();
b->Load(a);
textureId = GenerateOpenglBitmap(*b, false, false);
height = b->GetHeight();
width = b->GetWidth();
b->Free();
}
示例3: fprintf
static void
Main()
{
Bitmap bitmap;
bool success =
#ifdef USE_GDI
id.IsDefined()
? bitmap.Load(id)
:
#endif
bitmap.LoadFile(path);
if (!success)
fprintf(stderr, "Failed to load image\n");
}
示例4: main
int main() {
// SETUP //
// Set up the program with all possible drivers //
Setup::SetupProgram();
LOCK_VARIABLE( global_pressed );
LOCK_VARIABLE( global_released );
LOCK_FUNCTION( mouse_function );
mouse_callback = mouse_function;
// Set up the screen in windowed mode with the window size of 800 x 600 //
Setup::SetupScreen( 800, 600, WINDOWED );
// Load a bitmap //
Bitmap pointer;
pointer.Load( "Gfx/PointerAlpha.png", "Gfx/PointerAlpha.bmp" );
// Test if the bitmap was really loaded (maybe it didn't exist) //
if( !pointer ) {
allegro_message( "Couldn't load the bitmap!" );
exit( -1 );
}
// RENDERING //
// Draw the bitmap to the screen with the top-left coordinates of x = 200.0, y = 100.0 //
Circle cPointer( Vec2D( 10,10 ), 10 );
mousePointerLoop( cPointer );
while( keypressed())
readkey();
Rect rPointer( 0.0, 0.0, 20.0, 15.0 );
mousePointerLoop( rPointer );
while( keypressed())
readkey();
ol::Ellipse ePointer( 20.0, 10.0, 20.0, 10.0 );
mousePointerLoop( ePointer );
while( keypressed())
readkey();
polygonLoop( pointer );
return 0;
}
示例5: SetupVertices
/**
* Takes the pixel data from the Bitmap class and generates a vertices array with the Y value as the pixel value.
* @param Renderer* The renderer to use
* @param std::string The file name of the BMP file to load
* @param float The scaling of each pixel
* @param unsigned long The number of smoothing iteration to do
* @return void
*/
void Heightmap::SetupVertices(Renderer* argPRenderer, std::string argMapFileName, float argPixelScale, unsigned long argSmoothing)
{
// Load the bitmap
Bitmap* pBitmap = new Bitmap();
pBitmap->Load(argMapFileName);
// Fetch the bitmap data, width and height
unsigned char* pixelData = pBitmap->GetPixelData();
this->width = pBitmap->GetImageWidth();
this->height = pBitmap->GetImageHeight();
// Delete the bitmap
delete pBitmap;
this->offsetX = -(((float)(this->width * argPixelScale)) / 2);
this->offsetY = 0;
this->offsetZ = -(((float)(this->height * argPixelScale)) / 2);
// --- Create the vertex array ---
this->numVertices = this->width * this->height;
this->numPrimitives = this->numVertices * 2;
unsigned long vertexArraySize = this->numVertices * sizeof(TexturedVector3);
this->vertices = new TexturedVector3[this->numVertices];
for(long z = 0; z < this->height; z++)
{
for(long x = 0; x < this->width; x++)
{
long vIndex = (z * this->width) + x;
float pixelX = x * argPixelScale;
float pixelY = pixelData[vIndex] / 15.0f;
float pixelZ = z * argPixelScale;
this->vertices[vIndex].x = this->offsetX + pixelX;
this->vertices[vIndex].y = this->offsetY + pixelY;
this->vertices[vIndex].z = this->offsetZ + pixelZ;
this->vertices[vIndex].normal = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
this->vertices[vIndex].u = pixelX / ((float)(this->width * argPixelScale));
this->vertices[vIndex].v = 1 - (pixelZ / ((float)(this->height * argPixelScale)));
}
}
// Smooth the map
this->SmoothMap(argSmoothing);
// Calculate the normals
this->CalculateNormals();
// --- Create the index array ---
unsigned long numIndices = this->numPrimitives * 3;
unsigned long indexArraySize = numIndices * sizeof(short);
short* indices = new short[numIndices];
int index = 0;
for(long z = 0; z < (this->height - 1); z++)
{
for(long x = 0; x < (this->width - 1); x++)
{
// Top Left
indices[index] = (short)((z * this->width) + x);
index++;
// Bottom Left
indices[index] = (short)(((z + 1) * this->width) + x);
index++;
// Top Right
indices[index] = (short)((z * this->width) + (x + 1));
index++;
// Bottom Right
indices[index] = (short)(((z + 1) * this->width) + (x + 1));
index++;
// Top Right
indices[index] = (short)((z * this->width) + (x + 1));
index++;
// Bottom Left
indices[index] = (short)(((z + 1) * this->width) + x);
index++;
}
}
// Create the vertex buffer.
argPRenderer->CreateVertexBuffer(&this->pVertexBuffer, vertexArraySize, D3DFVFTexturedVector3, this->vertices);
// Create the index buffer.
argPRenderer->CreateIndexBuffer(&this->pIndexBuffer, indexArraySize, indices);
}
示例6: main
int main () {
rs = bs = gs =.5;
TheKeyBoard->Install (); //install the keyboard driver
//clip is set by default to 0,0 - 319, 199
//ScreenClip->Set (50,50, 319-50,199-50);
TheScreen->SetMode13h(); //set mode13h (don't forget)
ScreenPal->Load("animdemo.vpl", "animdemo.pal");
ScreenPal->PutToScreen();
char * myfiles [] = { "1.vbm", "2.vbm", "3.vbm", "4.vbm", "5.vbm", "6.vbm", "7.vbm",
"8.vbm","9.vbm","10.vbm" };
int mydurs [] = {
10,10,10,10,10,10,10,10,10,10
};
MasterAnim->AddAll(10, myfiles, mydurs);
Bitmap * MyBitmap = new Bitmap;
MyBitmap->Load("back.vbm");
InitCreatures();
ScreenPal->PrepareFadeIn();
MyBuffer->Clear();
MyBitmap->PutRegular18bit(0,0,MyBuffer->Memory);
DrawCreatures();
MyBuffer->CopyToScreen();
ScreenPal->FadeIn(1500);
float cinc = .1;
do {
//MyBuffer->Clear();
MoveCreatures ();
MyBitmap->PutRegular18bit(0,0,MyBuffer->Memory);
rs += cinc;
if (rs >= 1) {
rs= 1;
cinc = -cinc;
}
if (rs <= 0) {
rs= 0;
cinc = -cinc;
}
gs = bs = rs;
DrawCreatures();
//MasterAnim->Advance();
//MasterAnim->PutTransparent18bit(MyCreatures[0].x, MyCreatures[0].y,
// MyBuffer->Memory);
TheScreen->WaitVerticalRetraceStart();
//TheScreen->WaitVerticalRetraceStart();
//TheScreen->WaitVerticalRetraceStart();
MyBuffer->CopyToScreen();
//delay(1000);
} while (!TheKeyBoard->GetKeyState(KEY_ESC) );
ScreenPal->FadeOut(1500);
TheKeyBoard->Remove(); //remove keyboard driver (SUPERLY important!!!)
TheScreen->SetTextMode(); //set text mode (important!!!)
delete MasterAnim;
delete MyBitmap;
return 0;
}
示例7:
OlLoadResult PendingFileLoad::
ExecuteLoading( Bitmap &bmp ) {
return bmp.Load( filename )? OL_LR_SUCCESS : OL_LR_FAILURE;
}