示例#1
0
int initBitmapMemory(Bitmap* bitmap, int width, int height) {
	deleteBitmap(bitmap);

	(*bitmap).width = width;
	(*bitmap).height = height;

	(*bitmap).redWidth = width;
	(*bitmap).redHeight = height;

	(*bitmap).greenWidth = width;
	(*bitmap).greenHeight = height;

	(*bitmap).blueWidth = width;
	(*bitmap).blueHeight = height;

	int size = width*height;

	int resultCode = newUnsignedCharArray(size, &(*bitmap).red);
	if (resultCode != MEMORY_OK) {
		return resultCode;
	}

	resultCode = newUnsignedCharArray(size, &(*bitmap).green);
	if (resultCode != MEMORY_OK) {
		return resultCode;
	}

	resultCode = newUnsignedCharArray(size, &(*bitmap).blue);
	if (resultCode != MEMORY_OK) {
		return resultCode;
	}
}
void textureLoad(Texture *tex)
{	bitmap *bm;
	char flname[1024];

//	tex->flags &= texture_clearmask;
//	tex->flags |= flags;

//	texturelog->log("Attempting to load texture %s",tex->name);

	if (fileExists(tex->name))										// Check to see if the path + filename is valid ...
		txtcpy(flname, sizeof(flname), tex->name);					// if so, load that
	else
		fileFindInPath(flname, sizeof(flname), tex->name, texpath);	// Find the texture with our texture path

	if (!flname[0])													// nothing found ... fail
	{	texturelog->log("*** %s *** Missing texture.  Looked in %s",tex->name,texpath);
		if (!bm_MissingTexture)
		{	bm_MissingTexture = newbitmap("Missing Texture Standin",1,1,bitmap_ARGB32);
			*(uint32 *)(bm_MissingTexture->pixel) = 0xFFFF00FF;		// Purple
		}
		textureFromBitmap(bm_MissingTexture, tex);
		estimatedtexmemused += 4;
	}	else
	{	bm = newbitmap(flname,0);
		textureFromBitmap(bm, tex);
		deleteBitmap(bm);
	}
	if (tex->oemdata)
		texturelog->log("Create %i: %s",tex->texmemused/1024,flname);
}
示例#3
0
bool QWinThumbnailToolBarPrivate::IconicPixmapCache::setPixmap(const QPixmap &pixmap)
{
    if (pixmap.cacheKey() == m_pixmap.cacheKey())
        return false;
    deleteBitmap();
    m_pixmap = pixmap;
    return true;
}
示例#4
0
//--------------------------------------------------------------
// destructor
BitmapSurface::~BitmapSurface()
{
  if (m_bitmap != NULL)
    deleteBitmap();

  if (m_bitmapDC != NULL)
  {
    ReleaseDC(NULL, m_bitmapDC);
    m_bitmapDC = NULL;
  }
}
示例#5
0
void deleteOptionsMenu(OptionsMenu* state) {

	deleteBitmap(state->board);
	deleteBitmap(state->easyBtn);
	deleteBitmap(state->mediumBtn);
	deleteBitmap(state->hardBtn);
	deleteBitmap(state->btn30);
	deleteBitmap(state->btn90);
	deleteBitmap(state->btn120);
	deleteBitmap(state->backBtn);
	free(state);

}
示例#6
0
void deleteMainMenu(MainMenu* mm) {
	deleteBitmap(mm->Title1Bmp);
	deleteBitmap(mm->Title2Bmp);
	deleteBitmap(mm->SinglePlayBmp);
	deleteBitmap(mm->MultiPlayBmp);
	deleteBitmap(mm->HighScoreBmp);
	deleteBitmap(mm->ExitBmp);
	deleteBitmap(mm->Highlight);
	free(mm);
}
void killgraphics(void)
{	//killbillboard();
	select2DRenderTarget(NULL);
	killmaterial();
	if (_fctexture)		{	killtexture();	_fctexture = NULL;	}
	if (_fclighting)	{	killlighting();	_fclighting= NULL;	}
	if (fc_screenBitmap) deleteBitmap(fc_screenBitmap);				// ### This is a bug, we don't own the screen bitmap, the video driver does!
	if (shutDownVideo)
	{	if (shutDownVideo!=invalidvideoplugin)
			shutDownVideo();
	}
}
示例#8
0
//--------------------------------------------------------------
// set dimensions of surface
void BitmapSurface::setSurfaceSize(
  int width,
  int height)
{
  if (width == m_bitmapWidth && height == m_bitmapHeight)
    return;

  mgGenSurface::setSurfaceSize(width, height);
  deleteBitmap();
  createBitmap(width, height);
  m_bitmapWidth = width;
  m_bitmapHeight = height;
}
示例#9
0
	void allocate(const QSize &size)
	{
		deleteBitmap();
		
		switch (format)
		{
			case FIF_PNG:
				if (alphaEnabled)
					bitmap = FreeImage_AllocateT(FIT_RGBA16, size.width(), size.height());
				else
					bitmap = FreeImage_AllocateT(FIT_RGB16, size.width(), size.height());
				break;
			default:
				bitmap = FreeImage_Allocate(size.width(), size.height(), 24);
		}
	}
示例#10
0
HBITMAP QWinThumbnailToolBarPrivate::IconicPixmapCache::bitmap(const QSize &maxSize)
{
    if (m_pixmap.isNull())
        return 0;
    if (m_bitmap && m_size.width() <= maxSize.width() && m_size.height() <= maxSize.height())
        return m_bitmap;
    deleteBitmap();
    QPixmap pixmap = m_pixmap;
    if (pixmap.width() >= maxSize.width() || pixmap.height() >= maxSize.width())
        pixmap = pixmap.scaled(maxSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
    if (const HBITMAP bitmap = QtWin::toHBITMAP(pixmap, QtWin::HBitmapAlpha)) {
        m_size = pixmap.size();
        m_bitmap = bitmap;
    }
    return m_bitmap;
}
Texture *newTextureFromFile(const char *texname,uintf flags)
{	// Search the current texture directory to locate a suitable texture file
	bitmap *bm;
	char flname[1024];
	if (!texname) return NULL;
	if (!texname[0]) return NULL;

	// Look for an already loaded texture with the same name
	fileNameInfo(texname);
	tprintf(flname,sizeof(flname),"%s.%s",fileactualname,fileextension);
	Texture *tex = usedTexture;
	while (tex)
	{	if (txticmp(flname,tex->name)==0)
		{	// Texture already loaded
			tex->refcount++;
			return tex;
		}
		tex = tex->next;
	}

	// Allocate a new texture cell
	tex = newTexture(flname, 0, 0);	// ### This forces the texture to be 2D!!!
	tex->flags &= texture_clearmask;
	tex->flags |= flags;

	if (fileExists(texname))										// Check to see if the path + filename is valid ...
		txtcpy(flname, sizeof(flname), texname);					// if so, load that
	else
		fileFindInPath(flname, sizeof(flname), tex->name, texpath);	// Find the texture with our texture path

	if (!flname[0])													// nothing found ... fail
	{	texturelog->log("*** %s *** Missing texture.  Looked in %s",tex->name,texpath);
		if (!bm_MissingTexture)
		{	bm_MissingTexture = newbitmap("Missing Texture Standin",1,1,bitmap_ARGB32);
			*(uint32 *)(bm_MissingTexture->pixel) = 0xFFFF00FF;		// Purple
		}
		textureFromBitmap(bm_MissingTexture, tex);
		estimatedtexmemused += 4;
	}	else
	{	bm = newbitmap(flname,0);
		textureFromBitmap(bm, tex);
		deleteBitmap(bm);
	}
	if (tex->oemdata)
		texturelog->log("Create %i: %s",tex->texmemused/1024,flname);
	return tex;
}
示例#12
0
void stopChopperDrop(ChopperDrop* game)
{
	// unsubscribe devices
	unsubscribeKeyboard();
	unsubscribeTimer();
	unsubscribeMouse();

	deleteBitmap(game->mouseCursor);

	deleteCurrentState(game);

	disableMouse();
	cleanBuffer();
	deleteMouse();
	deleteTimer(game->timer);
	deleteDate(game->date);

	free(game);
}
示例#13
0
int Java_com_lightbox_android_photoprocessing_PhotoProcessing_nativeLoadResizedJpegBitmap(JNIEnv* env, jobject thiz, jbyteArray bytes, jint jpegSize, jint maxPixels) {
	char* jpegData = (char*) (*env)->GetPrimitiveArrayCritical(env, bytes, NULL);

	if (jpegData == NULL) {
		LOGE("jpeg data was null");
		return JNI_GET_INT_ARRAY_ERROR;
	}

	int resultCode = decodeJpegData(jpegData, jpegSize, maxPixels, &bitmap);
	if (resultCode != MEMORY_OK) {
		deleteBitmap(&bitmap);
		LOGE("error decoding jpeg resultCode=%d", resultCode);
		return resultCode;
	}

	(*env)->ReleasePrimitiveArrayCritical(env, bytes, jpegData, 0);

	return MEMORY_OK;
}
示例#14
0
int decodeImage(char const *filename, Bitmap* bitmap) {
    // Delete the current bitmap, just in case
    deleteBitmap(bitmap);

    int width, height, comp;
    unsigned char *data = stbi_load(filename, &width, &height, &comp, 0);
    LOGI("stbi_image Loaded Image. %dx%d, Components: %d. Size: %d", width, height, comp, sizeof(data));

    // Check for bad decode...
    if (!data || comp <= 2) {
        // Free Image
        stbi_image_free(data);
        return DECODE_ERROR;
    }

    int size = width * height;

    // Create Char Arrays to store pixel data
    unsigned char* red;
    unsigned char* green;
    unsigned char* blue;

    int resultCode = newUnsignedCharArray(size, &red);
    if (resultCode != MEMORY_OK) {
        return resultCode;
    }
    resultCode = newUnsignedCharArray(size, &green);
    if (resultCode != MEMORY_OK) {
        return resultCode;
    }
    resultCode = newUnsignedCharArray(size, &blue);
    if (resultCode != MEMORY_OK) {
        return resultCode;
    }

    // Split values into R, G, B
    int x, y;
    int index = 0;
    for (y = 0; y < height; y++)
    {
        for (x = 0; x < width; x++)
        {
            red[index] = data[index*comp];
            green[index] = data[(index*comp)+1];
            blue[index] = data[(index*comp)+2];
            index++;
        }
    }

    // Free Image
    stbi_image_free(data);

    (*bitmap).red = red;
    (*bitmap).green = green;
    (*bitmap).blue = blue;
    (*bitmap).redHeight = height;
    (*bitmap).redWidth = width;
    (*bitmap).greenHeight = height;
    (*bitmap).greenWidth = width;
    (*bitmap).blueHeight = height;
    (*bitmap).blueWidth = width;

    return MEMORY_OK;
}
示例#15
0
	~Data()
	{
		deleteBitmap();
	}
示例#16
0
EWXWEXPORT(void,wxBitmap_SafeDelete)(wxBitmap* obj)
{
  deleteBitmap(obj);
}
示例#17
0
void deleteSaveMenu(SaveMenu* sm){
	deleteBitmap(sm->Exit);
	deleteBitmap(sm->Highlight);
	deleteBitmap(sm->Highlight2);
	free(sm);
}
示例#18
0
void deletePauseMenu(PauseMenu* pm){
	deleteBitmap(pm->ResumeBmp);
	deleteBitmap(pm->Highlight);
	deleteBitmap(pm->ExitBmp);
	free(pm);
}
示例#19
0
void Java_editimage_fliter_PhotoProcessing_nativeDeleteBitmap(JNIEnv *env, jobject thiz) {
	deleteBitmap(&bitmap);
}
示例#20
0
void deleteNewRecordMenu(newRecordMenu* menu){
	deleteBitmap(menu->fundo);
	free(menu);
}
示例#21
0
文件: Bomb.c 项目: mgpsp/LCOM-FEUP
void deleteBomb(Bomb* bomb)
{
	deleteBitmap(bomb->sprite);
	free(bomb);
}
// Internal function - Called to load up a texture map - file is known to exist
Texture *textureFromBitmap(bitmap *loadbm, Texture *tex)
{	bitmap *swizzleBm, *scaleBm, *resizeCanvasSrc;
	bool mustSwizzle = false;
	bool mustScale = false;

	// Step 1: Check for a need to swizzle (if the video card doesn't support this texture mode)
	uintf dataType = loadbm->flags & (bitmap_DataTypeMask | bitmap_DataInfoMask);
	// ### This code is not yet complete, must leave this block with 'swizzleBM' pointing to swizzled bitmap data

	// If Video card only handles 'Power-of-2' texture dimensions
	bool resizeCanvas=false;
	// if (GLESWarnings) //!(videoFeatures & videodriver_nonP2Tex))
	{	uintf newCanvasWidth = loadbm->width;
		uintf newCanvasHeight = loadbm->height;

		if (!isPow2(loadbm->width))
		{	resizeCanvas=true;
			newCanvasWidth=nextPow2(loadbm->width);
		}
		if (!isPow2(loadbm->height))
		{	resizeCanvas=true;
			newCanvasHeight=nextPow2(loadbm->height);
		}
		if (resizeCanvas)
		{	resizeCanvasSrc = loadbm;
			loadbm = newbitmap("resizeCanvasP2Tex",newCanvasWidth,newCanvasHeight,bitmap_ARGB32);
			uintf x,y;
			uint32 *src32 = (uint32 *)resizeCanvasSrc->pixel;
			uint32 *dst32 = (uint32 *)loadbm->pixel;
			for (y=0; y<resizeCanvasSrc->height; y++)
			{	uint32 *src = &src32[y*(resizeCanvasSrc->width)];
				uint32 *dst = &dst32[y*newCanvasWidth];
				for (x=0; x<resizeCanvasSrc->width; x++)
					*dst++ = *src++;
				for (;x<newCanvasWidth; x++)
					*dst++ = 0;
			}
			for (;y<newCanvasHeight; y++)
			{	uint32 *dst = &dst32[y*newCanvasWidth];
				for (x=0; x<newCanvasWidth; x++)
					*dst++=0;
			}
		}

/*		// Work out X scale
		uintf size = 1;
		while (size<=maxtexwidth)
		{	if (newx<=size) break;
			size <<=1;
		}
		if (size>maxtexwidth) size = maxtexwidth;
		newx = size;

		// Work out Y scale
		size = 1;
		while (size<=maxtexheight)
		{	if (newy<=size) break;
			size <<=1;
		}
		if (size>maxtexheight) size = maxtexheight;
		newy = size;
*/
	}

	// Step 2: Check if we need to resize - this may change swizzle mode
	uintf newx = loadbm->width;
	uintf newy = loadbm->height;
	if (newx>maxtexwidth)
		newx = maxtexwidth;
	if (newy>maxtexheight)
		newy = maxtexheight;

	if (newx!=loadbm->width || newy!=loadbm->height)
	{	dataType = bitmap_DataTypeRGB | bitmap_RGB_32bit;
		mustSwizzle = true;
		mustScale = true;
	}

	if (mustSwizzle)
	{	dataType |= loadbm->flags & bitmap_AlphaMask;
		swizzleBm = SwizzleBitmap(loadbm, dataType);
	}	else
		swizzleBm = loadbm;

	if (mustScale)
	{	// Bitmap needs to be resized before hardware will accept it
		scaleBm = scalebitmap(swizzleBm,newx,newy);
	}	else
		scaleBm = swizzleBm;

	// If we don't have a texture provided, create a new one
	if (!tex)
		tex = newTexture(NULL, 0, 0);
	downloadbitmaptex(tex, scaleBm, 0);
	estimatedtexmemused += tex->texmemused;
	if (mustScale)
		deleteBitmap(scaleBm);
	if (mustSwizzle)
		deleteBitmap(swizzleBm);
	if (resizeCanvas)
	{	deleteBitmap(loadbm);
		loadbm = resizeCanvasSrc;
		tex->flags |= texture_canvasSize;
		tex->UVscale.x = (float)loadbm->width / (float)tex->width;
		tex->UVscale.y = (float)loadbm->height/ (float)tex->height;
	}
	return tex;
}
示例#23
0
void deleteGameOverState(GameOverState* state)
{
	deleteBitmap(state->background);
	free(state);
}
示例#24
0
void deleteHighScores(HighScores* hs){
	deleteBitmap(hs->HighScore);
	deleteBitmap(hs->Exit);
	deleteBitmap(hs->Highlight);
	free(hs);
}
示例#25
0
void deleteBullet(Bullet* b){
	if (b->inUse)
		deleteBitmap(b->bullet_bmp);
	free(b);
}
示例#26
0
文件: Chopper.c 项目: mgpsp/LCOM-FEUP
void deleteChopper(Chopper* chopper)
{
	deleteBitmap(chopper->spriteRight);
	deleteBitmap(chopper->spriteLeft);
	free(chopper);
}
示例#27
0
void Java_com_lightbox_android_photoprocessing_PhotoProcessing_nativeDeleteBitmap(JNIEnv* env, jobject thiz) {
	deleteBitmap(&bitmap);
}