コード例 #1
0
ファイル: Global.cpp プロジェクト: musiccube375/project-jb
void CGlobal::LoadBitmaps()
{
	DeleteBitmaps();

	CString strFileName(_T(""));
	CString sModulePath = GetModulePath() + _T("\\");

	for(UINT i=0; i<IDX_BMP_MAX; i++)
	{
		strFileName = GetBitmapFileName(i);
		if( strFileName.IsEmpty() )
			continue;
		
		strFileName = sModulePath + strFileName;

		m_infoBitmap[i].hBitmap = (HBITMAP)::LoadImage(::AfxGetInstanceHandle(), 
											(LPCTSTR)strFileName, 
											IMAGE_BITMAP, 
											0, 
											0, 
											LR_LOADFROMFILE|LR_CREATEDIBSECTION|LR_DEFAULTSIZE);

		::GetObject(m_infoBitmap[i].hBitmap, sizeof(BITMAP), &m_infoBitmap[i].bitmap);
	}
}
コード例 #2
0
void MythD3D9Painter::Begin(QPaintDevice *parent)
{
    if (!m_render)
    {
        if (!InitD3D9(parent))
        {
            LOG(VB_GENERAL, LOG_ERR, "Failed to create D3D9 render.");
            return;
        }
    }

    DeleteBitmaps();

    if (!m_target)
    {
        bool dummy;
        m_render->Test(dummy); // TODO recreate if necessary
    }
    else if (!m_target->SetAsRenderTarget())
    {
        LOG(VB_GENERAL, LOG_ERR, "Failed to enable offscreen buffer.");
        return;
    }

    if (m_target)
        m_render->ClearBuffer();
    if (m_swap_control)
        m_render->Begin();
    MythPainter::Begin(parent);
}
コード例 #3
0
KeyboardWidget::~KeyboardWidget()
{
    DeleteBitmaps();
    delete[] rcWhite;
    delete[] rcBlack;
    ClearNotes();
    delete recTail;
    delete recHead;
}
コード例 #4
0
void MythD3D9Painter::Teardown(void)
{
    MythPainter::Teardown();
    ClearCache();
    DeleteBitmaps();

    m_ImageBitmapMap.clear();
    m_ImageExpireList.clear();
    m_bitmapDeleteList.clear();

    if (m_render)
    {
        m_render->DecrRef();
        m_render = NULL;
    }
}
コード例 #5
0
// ---------------------------------------------------------------------------
// CAknBatteryStrength::HandleResourceChange
// ---------------------------------------------------------------------------
//
void CAknBatteryStrength::HandleResourceChange( TInt aType )
    {
    if ( aType==KEikDynamicLayoutVariantSwitch ||
         aType == KEikColorResourceChange ||
         aType == KAknsMessageSkinChange)
        {
        DeleteBitmaps(); // SizeChanged reloads needed bitmaps
        SizeChanged();

        if ( aType == KEikDynamicLayoutVariantSwitch )
            {
            SetBatteryLevel( iBatteryLevel ); // refreshes battery level offsets
            }

        DrawDeferred();
        }
    }
コード例 #6
0
D3D9Image* MythD3D9Painter::GetImageFromCache(MythImage *im)
{
    if (m_ImageBitmapMap.contains(im))
    {
        if (!im->IsChanged())
        {
            m_ImageExpireList.remove(im);
            m_ImageExpireList.push_back(im);
            return m_ImageBitmapMap[im];
        }
        else
        {
            DeleteFormatImagePriv(im);
        }
    }

    im->SetChanged(false);
    D3D9Image *newimage = NULL;
    if (m_render)
        newimage = new D3D9Image(m_render,im->size());

    if (newimage && newimage->IsValid())
    {
        CheckFormatImage(im);
        m_HardwareCacheSize += newimage->GetDataSize();
        newimage->UpdateImage(im);
        m_ImageBitmapMap[im] = newimage;
        m_ImageExpireList.push_back(im);

        while (m_HardwareCacheSize > m_MaxHardwareCacheSize)
        {
            MythImage *expiredIm = m_ImageExpireList.front();
            m_ImageExpireList.pop_front();
            DeleteFormatImagePriv(expiredIm);
            DeleteBitmaps();
        }
    }
    else
    {
       LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create D3D9 UI bitmap.");
       delete newimage;
       newimage = NULL;
    }

    return newimage;
}
コード例 #7
0
uint MythVDPAUPainter::GetTextureFromCache(MythImage *im)
{
    if (m_ImageBitmapMap.contains(im))
    {
        if (!im->IsChanged())
        {
            m_ImageExpireList.remove(im);
            m_ImageExpireList.push_back(im);
            return m_ImageBitmapMap[im];
        }
        else
        {
            DeleteFormatImagePriv(im);
        }
    }

    im->SetChanged(false);
    uint newbitmap = 0;
    if (m_render)
        newbitmap = m_render->CreateBitmapSurface(im->size());

    if (newbitmap)
    {
        CheckFormatImage(im);
        m_render->UploadMythImage(newbitmap, im);
        m_ImageBitmapMap[im] = newbitmap;
        m_ImageExpireList.push_back(im);
        m_HardwareCacheSize += m_render->GetBitmapSize(newbitmap);
        while (m_HardwareCacheSize > m_MaxHardwareCacheSize)
        {
            MythImage *expiredIm = m_ImageExpireList.front();
            m_ImageExpireList.pop_front();
            DeleteFormatImagePriv(expiredIm);
            DeleteBitmaps();
        }
    }
    else
    {
       LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create VDPAU UI bitmap.");
    }

    return newbitmap;
}
コード例 #8
0
void MythVDPAUPainter::Begin(QPaintDevice *parent)
{
    if (!m_render)
    {
        if (!InitVDPAU(parent))
        {
            LOG(VB_GENERAL, LOG_ERR, "Failed to create VDPAU render.");
            return;
        }
    }

    if (m_render->WasPreempted())
        ClearCache();
    DeleteBitmaps();

    if (m_target)
        m_render->DrawBitmap(0, m_target, NULL, NULL);
    else if (m_swap_control)
        m_render->WaitForFlip();

    MythPainter::Begin(parent);
}
コード例 #9
0
ファイル: imglist.c プロジェクト: cixonline/ameol
/* Adds an image or images to an image list, generating a mask from the
 * given bitmap.
 */
int WINAPI EXPORT Amctl_ImageList_AddMasked( HIMAGELIST himl, HBITMAP hbmImage, COLORREF crMask )
{
   HBITMAP hbmpOldDest;
   HBITMAP hbmpOldSrc;
   HBITMAP hbmpOldMask;
   BITMAP bmp;
   HDC hdcSrc;
   HDC hdcDest;
   HDC hdcMask;
   HDC hdc;
   int cImageOffset;
   int cImages;
   int dx;

   /* If no mask, can't do this.
    */
   if( !( himl->flags & ILC_MASK ) )
      return( -1 );

   /* Get the size of the bitmap. The number of items to be added will be
    * the width of the bitmap divided by the size of each one.
    */
   GetObject( hbmImage, sizeof( BITMAP ), &bmp );
   cImages = ( bmp.bmWidth + ( himl->cx - 1 ) ) / himl->cx;

   /* If we need more room, delete the existing bitmaps and create new ones
    * up to the specified size.
    */
   if( himl->cImages + cImages > himl->cSlots )
      if( himl->cGrow )
         {
         int cNewSize;

         DeleteBitmaps( himl );
         cNewSize = ( ( ( himl->cImages + cImages ) / himl->cGrow ) + 1 ) * himl->cGrow;
         CreateEmptyBitmaps( himl, himl->cImages + cImages, cNewSize );
         }
      else
         return( -1 );

   /* Offset of these new bitmaps.
    */
   cImageOffset = himl->cImages;
   dx = cImageOffset * himl->cx;

   /* Initialise working stuff.
    */
   hdc = GetDC( NULL );
   hdcSrc = CreateCompatibleDC( hdc );
   hdcDest = CreateCompatibleDC( hdc );
   hdcMask = CreateCompatibleDC( hdc );
   hbmpOldSrc = SelectBitmap( hdcSrc, hbmImage );

   /* Copy the image into the image bitmap.
    */
   hbmpOldDest = SelectBitmap( hdcDest, himl->hbmp );
   BitBlt( hdcDest, dx, 0, himl->cx * cImages, himl->cy, hdcSrc, 0, 0, SRCCOPY );

   /* Create the mask.
    */
   hbmpOldMask = SelectBitmap( hdcMask, himl->hbmpMask );
   SetBkColor( hdcSrc, crMask );
   BitBlt( hdcMask, dx, 0, himl->cx * cImages, himl->cy, hdcSrc, 0, 0, SRCCOPY );

   /* Set the total number of images in the list.
    */
   himl->cImages += cImages;
   himl->crTransparent = crMask;

   /* Clean up at the end.
    */
   SelectBitmap( hdcMask, hbmpOldMask );
   SelectBitmap( hdcDest, hbmpOldDest );
   SelectBitmap( hdcSrc, hbmpOldSrc );
   DeleteDC( hdcMask );
   DeleteDC( hdcSrc );
   DeleteDC( hdcDest );
   ReleaseDC( NULL, hdc );
   return( cImageOffset );
}
コード例 #10
0
ファイル: imglist.c プロジェクト: cixonline/ameol
/* Destroys an image list.
 */
BOOL WINAPI EXPORT Amctl_ImageList_Destroy( HIMAGELIST himl )
{
   DeleteBitmaps( himl );
   FreeMemory( &himl );
   return( TRUE );
}
コード例 #11
0
ファイル: Global.cpp プロジェクト: musiccube375/project-jb
CGlobal::~CGlobal()
{
	DeleteBitmaps();
	DeleteFonts();
	DeleteIcons();
}
コード例 #12
0
void MythD3D9Painter::FreeResources(void)
{
    ClearCache();
    DeleteBitmaps();
}
コード例 #13
0
void KeyboardWidget::Setup()
{
    delete[] rcWhite;
    delete[] rcBlack;
    DeleteBitmaps();

    colorMap.Find("kwup", kclr[0]);
    colorMap.Find("kwdn", kclr[1]);
    colorMap.Find("kbup", kclr[2]);
    colorMap.Find("kbdn", kclr[3]);

    rcWhite = new wdgRect[whtKeys];
    rcBlack = new wdgRect[blkKeys];

    // First calculate an appropriate width/height ratio for keys
    // based on the overall size of the display area.
    // Start by calculating the width of a key as the
    // total width divided by the number of keys and the
    // height as the total height of the window. (We assume
    // the window is rectangular, wider than high.) A typical
    // piano keyboard has a ratio of 6/1 for the length
    // to width of a white key. Thus - if the resulting height
    // is more than 6 times the width, reduce the height accordingly.
    // If the resulting height is less than 5 times the width, reduce the
    // width accordingly. The black keys have a width ratio of app. 7/15 the
    // size of a white key, but the gaps in between the keys make them appear
    // wider and we use 7/10 as the ratio to make it look right and give the
    // user more area to hit with the mouse. Finally, the keyboard is centered
    // left-right at the top of the window.
    int widWhite = area.w / whtKeys;
    int hiWhite = area.h;
    if (hiWhite > (6*widWhite))
        hiWhite = 6*widWhite;
    else if (hiWhite < (5*widWhite))
        widWhite = hiWhite / 5;
    int hiBlack = (hiWhite * 2) / 3;
    int widBlack = (widWhite * 7) / 10;
    int space = (area.w - (widWhite * whtKeys)) / 2;

    // Pre-calculate the rectangles of the keys. White keys are
    // equally spaced. Black keys repeat in the 2, 3 pattern with
    // a gap inbetween the groups equal to the width of a white key.
    int xWhite = space;
    int xBlack = space + widWhite - (widBlack / 2);
    int i, on;
    int ndxw = 0;
    int ndxb = 0;
    for (on = 0; on < octs; on++)
    {
        for (i = 0; i < 7; i++)
        {
            rcWhite[ndxw].x = (int) xWhite + area.x;
            rcWhite[ndxw].y = area.y;
            rcWhite[ndxw].w = (int) widWhite;
            rcWhite[ndxw].h = hiWhite;
            xWhite += widWhite;
            ndxw++;
        }

        for (i = 0; i < 2; i++)
        {
            rcBlack[ndxb].x = (int) xBlack + area.x;
            rcBlack[ndxb].y = area.y;
            rcBlack[ndxb].w = (int) widBlack;
            rcBlack[ndxb].h = hiBlack;
            xBlack += widWhite;
            ndxb++;
        }

        xBlack += widWhite;
        for ( i = 0; i < 3; i++)
        {
            rcBlack[ndxb].x = (int) xBlack + area.x;
            rcBlack[ndxb].y = area.y;
            rcBlack[ndxb].w = (int) widBlack;
            rcBlack[ndxb].h = hiBlack;
            xBlack += widWhite;
            ndxb++;
        }
        xBlack += widWhite;
    }

    // pitch class conversion for white and black keys
    knWhite[0] = 0;
    knWhite[1] = 2;
    knWhite[2] = 4;
    knWhite[3] = 5;
    knWhite[4] = 7;
    knWhite[5] = 9;
    knWhite[6] = 11;
    knBlack[0] = 1;
    knBlack[1] = 3;
    knBlack[2] = 6;
    knBlack[3] = 8;
    knBlack[4] = 10;

    lastKey = -1;
    rcLastKey = 0;
    CreateBitmaps();
}
コード例 #14
0
 virtual int OnExit() { DeleteBitmaps(); return 0; }
コード例 #15
0
ファイル: Icon.cpp プロジェクト: AmirAbrams/haiku
status_t
BIcon::SetTo(const BBitmap* bitmap, uint32 flags)
{
	if (!bitmap->IsValid())
		return B_BAD_VALUE;

	DeleteBitmaps();

	// check the color space
	bool hasAlpha = false;
	bool canUseForMakeBitmaps = false;

	switch (bitmap->ColorSpace()) {
		case B_RGBA32:
		case B_RGBA32_BIG:
			hasAlpha = true;
			// fall through
		case B_RGB32:
		case B_RGB32_BIG:
			canUseForMakeBitmaps = true;
			break;

		case B_UVLA32:
		case B_LABA32:
		case B_HSIA32:
		case B_HSVA32:
		case B_HLSA32:
		case B_CMYA32:
		case B_RGBA15:
		case B_RGBA15_BIG:
		case B_CMAP8:
			hasAlpha = true;
			break;

		default:
			break;
	}

	BBitmap* trimmedBitmap = NULL;

	// trim the bitmap, if requested and the bitmap actually has alpha
	status_t error;
	if ((flags & (B_TRIM_ICON_BITMAP | B_TRIM_ICON_BITMAP_KEEP_ASPECT)) != 0
		&& hasAlpha) {
		if (bitmap->ColorSpace() == B_RGBA32) {
			error = _TrimBitmap(bitmap,
				(flags & B_TRIM_ICON_BITMAP_KEEP_ASPECT) != 0, trimmedBitmap);
		} else {
			BBitmap* rgb32Bitmap = _ConvertToRGB32(bitmap, true);
			if (rgb32Bitmap != NULL) {
				error = _TrimBitmap(rgb32Bitmap,
					(flags & B_TRIM_ICON_BITMAP_KEEP_ASPECT) != 0,
					trimmedBitmap);
				delete rgb32Bitmap;
			} else
				error = B_NO_MEMORY;
		}

		if (error != B_OK)
			return error;

		bitmap = trimmedBitmap;
		canUseForMakeBitmaps = true;
	}

	// create the bitmaps
	if (canUseForMakeBitmaps) {
		error = _MakeBitmaps(bitmap, flags);
	} else {
		if (BBitmap* rgb32Bitmap = _ConvertToRGB32(bitmap, true)) {
			error = _MakeBitmaps(rgb32Bitmap, flags);
			delete rgb32Bitmap;
		} else
			error = B_NO_MEMORY;
	}

	delete trimmedBitmap;

	return error;
}