本文整理汇总了C++中CreateDIBitmap函数的典型用法代码示例。如果您正苦于以下问题:C++ CreateDIBitmap函数的具体用法?C++ CreateDIBitmap怎么用?C++ CreateDIBitmap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreateDIBitmap函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateDIBitmap
void CBC_TwoDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
int32_t& e) {
if (m_bFixedSize) {
pOutBitmap = CreateDIBitmap(m_Width, m_Height);
} else {
pOutBitmap = CreateDIBitmap(m_output->GetWidth(), m_output->GetHeight());
}
if (!pOutBitmap) {
e = BCExceptionFailToCreateBitmap;
return;
}
pOutBitmap->Clear(m_backgroundColor);
int32_t leftPos = 0;
int32_t topPos = 0;
if (m_bFixedSize) {
leftPos = (m_Width - m_output->GetWidth()) / 2;
topPos = (m_Height - m_output->GetHeight()) / 2;
}
for (int32_t x = 0; x < m_output->GetWidth(); x++) {
for (int32_t y = 0; y < m_output->GetHeight(); y++) {
if (m_output->Get(x, y)) {
pOutBitmap->SetPixel(leftPos + x, topPos + y, m_barColor);
}
}
}
if (!m_bFixedSize) {
CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height);
delete pOutBitmap;
pOutBitmap = pStretchBitmap;
}
}
示例2: image_make_icon_handle
HICON
image_make_icon_handle( Handle img, Point size, Point * hotSpot)
{
PIcon i = ( PIcon) img;
HICON r;
ICONINFO ii;
int bpp = i-> type & imBPP;
Bool noSZ = i-> w != size. x || i-> h != size. y;
Bool noBPP = bpp != 1 && bpp != 4 && bpp != 8 && bpp != 24;
HDC dc;
XBITMAPINFO bi;
Bool notAnIcon = !kind_of( img, CIcon);
ii. fIcon = hotSpot ? false : true;
ii. xHotspot = hotSpot ? hotSpot-> x : 0;
ii. yHotspot = hotSpot ? hotSpot-> y : 0;
if ( noSZ || noBPP) {
i = ( PIcon)( i-> self-> dup( img));
if ( noSZ)
i-> self-> set_size(( Handle) i, size);
if ( noBPP)
i-> self-> set_type(( Handle) i,
( bpp < 4) ? 1 :
(( bpp < 8) ? 4 :
(( bpp < 24) ? 8 : 24))
);
}
if (!( dc = dc_alloc())) {
if (( Handle) i != img) Object_destroy(( Handle) i);
return NULL;
}
image_get_binfo(( Handle)i, &bi);
if ( bi. bmiHeader. biClrUsed > 0)
bi. bmiHeader. biClrUsed = bi. bmiHeader. biClrImportant = i-> palSize;
if ( !( ii. hbmColor = CreateDIBitmap( dc, &bi. bmiHeader, CBM_INIT,
i-> data, ( BITMAPINFO*) &bi, DIB_RGB_COLORS))) apiErr;
bi. bmiHeader. biBitCount = bi. bmiHeader. biPlanes = 1;
bi. bmiColors[ 0]. rgbRed = bi. bmiColors[ 0]. rgbGreen = bi. bmiColors[ 0]. rgbBlue = 0;
bi. bmiColors[ 1]. rgbRed = bi. bmiColors[ 1]. rgbGreen = bi. bmiColors[ 1]. rgbBlue = 255;
if ( !( ii. hbmMask = CreateDIBitmap( dc, &bi. bmiHeader, CBM_INIT,
notAnIcon ? NULL : i-> mask, ( BITMAPINFO*) &bi, DIB_RGB_COLORS))) apiErr;
dc_free();
if ( !( r = CreateIconIndirect( &ii))) apiErr;
DeleteObject( ii. hbmColor);
DeleteObject( ii. hbmMask);
if (( Handle) i != img) Object_destroy(( Handle) i);
return r;
}
示例3: BC_EXCEPTION_CHECK_ReturnVoid
void CBC_OneDimWriter::RenderBitmapResult(CFX_DIBitmap*& pOutBitmap,
const CFX_WideStringC& contents,
int32_t& e) {
if (!m_output)
BC_EXCEPTION_CHECK_ReturnVoid(e);
pOutBitmap = CreateDIBitmap(m_output->GetWidth(), m_output->GetHeight());
pOutBitmap->Clear(m_backgroundColor);
if (!pOutBitmap) {
e = BCExceptionFailToCreateBitmap;
return;
}
for (int32_t x = 0; x < m_output->GetWidth(); x++) {
for (int32_t y = 0; y < m_output->GetHeight(); y++) {
if (m_output->Get(x, y)) {
pOutBitmap->SetPixel(x, y, m_barColor);
}
}
}
int32_t i = 0;
for (; i < contents.GetLength(); i++)
if (contents.GetAt(i) != ' ') {
break;
}
if (m_locTextLoc != BC_TEXT_LOC_NONE && i < contents.GetLength()) {
ShowChars(contents, pOutBitmap, nullptr, nullptr, m_barWidth, m_multiple,
e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
}
CFX_DIBitmap* pStretchBitmap = pOutBitmap->StretchTo(m_Width, m_Height);
delete pOutBitmap;
pOutBitmap = pStretchBitmap;
}
示例4: GetToolbarBitmap
extern "C" AFX_EXT_API HBITMAP GetToolbarBitmap(LPWORD wC)
{
HBITMAP hBitmap = NULL;
/*if ( NULL == hInst )
hInst = ::AfxFindResourceHandle( IDB_TOOLBAR32_BMP, RT_BITMAP);*/
HRSRC hRsrc = ::FindResource(Standard2DDLL.hResource,
MAKEINTRESOURCE(IDB_TOOLBAR32_BMP), RT_BITMAP);
if ( hRsrc ){
HGLOBAL hglb = LoadResource(Standard2DDLL.hResource, hRsrc);
if ( hglb ){
// „итаем заголовок
LPBITMAPINFO pbi = (LPBITMAPINFO)LockResource(hglb);
if (pbi ) {
/*if ( lpnWidth )
*lpnWidth = pbi->bmiHeader.biWidth;
if ( lpnHeight )
*lpnHeight = pbi->bmiHeader.biHeight;*/
if ( wC )
*wC = pbi->bmiHeader.biBitCount;
// „итаем данные
HDC hdc = GetDC( NULL );
//hBitmap = CreateDIBitmap( hdc, &pbi->bmiHeader, CBM_INIT, pbi->bmiColors, pbi, DIB_RGB_COLORS);
// BYTE* pData = (BYTE*)pbi + sizeof(BITMAPINFO) + pbi->bmiHeader.biClrUsed * sizeof(COLORREF);
BYTE* pData = (BYTE*)pbi + sizeof(BITMAPINFOHEADER) + pbi->bmiHeader.biClrUsed * sizeof(COLORREF);
hBitmap = CreateDIBitmap( hdc, &pbi->bmiHeader, CBM_INIT, (void*)pData, pbi, DIB_RGB_COLORS);
// hBitmap = CreateDIBSection( hdc, pbi, DIB_RGB_COLORS, (LPVOID*)&pbi->bmiColors, NULL, NULL );
::ReleaseDC (NULL, hdc);
}
FreeResource( hglb );
}
}
return hBitmap;
}
示例5: MyCreateBitmap
HBITMAP MyCreateBitmap(
HDC hdc,
INT cx,
INT cy,
INT nColors)
{
BITMAPINFOHEADER bmih;
if (nColors == 2) {
return CreateBitmap(cx, cy, 1, 1, NULL);
}
else {
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biWidth = cx;
bmih.biHeight = cy;
bmih.biPlanes = 1; // 1 plane, 4 bpp is
bmih.biBitCount = 4; // 16 colors.
bmih.biCompression =
bmih.biSizeImage =
bmih.biXPelsPerMeter =
bmih.biYPelsPerMeter =
bmih.biClrUsed =
bmih.biClrImportant = 0;
return CreateDIBitmap(hdc, &bmih, 0L, NULL, NULL, 0);
}
}
示例6: FARINTERNAL_
FARINTERNAL_(HBITMAP) UtConvertDibToBitmap(HANDLE hDib)
{
VDATEHEAP();
LPBITMAPINFOHEADER lpbmih;
HDC hdc; // the device context to create the bitmap for
size_t uBitsOffset; // the offset to where the image begins in the DIB
HBITMAP hBitmap; // the bitmap we'll return
if (!(lpbmih = (LPBITMAPINFOHEADER)GlobalLock(hDib)))
return(NULL);
if (!(hdc = GetDC(NULL))) // Get screen DC.
{
// REVIEW: we may have to use the target device of this
// cache node.
return(NULL);
}
uBitsOffset = sizeof(BITMAPINFOHEADER) +
(lpbmih->biClrUsed ? lpbmih->biClrUsed :
UtPaletteSize(lpbmih));
hBitmap = CreateDIBitmap(hdc, lpbmih, CBM_INIT,
((BYTE *)lpbmih)+uBitsOffset,
(LPBITMAPINFO) lpbmih, DIB_RGB_COLORS);
// release the DC
ReleaseDC(NULL, hdc);
return hBitmap;
}
示例7: CreateDC
HBITMAP CScreenSnap::ChangeDataToBitmap(BYTE* pData)
{
BITMAPFILEHEADER* pbmfh ; // DIB位图文件头
HBITMAP hBitmap ;
pbmfh = (BITMAPFILEHEADER *)pData;
if (pbmfh->bfType != * (WORD *) "BM")
return NULL ;
HDC hdc = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
if(hdc == NULL)
return NULL;
// 创建DDB位图
hBitmap = CreateDIBitmap(hdc,
(BITMAPINFOHEADER *) (pbmfh + 1),
CBM_INIT,
(BYTE *) pbmfh + pbmfh->bfOffBits,
(BITMAPINFO *) (pbmfh + 1),
DIB_RGB_COLORS) ;
DeleteDC(hdc);
return hBitmap ;
}
示例8: DIBToBitmap
// Umformen einer DIB in eine DDB
HBITMAP CBildObjekt :: DIBToBitmap (void)
{
BITMAPINFOHEADER *lpBI;
HPALETTE hPalT;
HDC hDC;
HBITMAP hBM;
if (!m_hDIB) return NULL;
// Bitmapheader
lpBI = (BITMAPINFOHEADER *)GlobalLock (m_hDIB);
if (!lpBI) return NULL;
// Palette realisieren
hDC = :: GetDC (NULL);
if (m_hPal) {
hPalT = SelectPalette (hDC, m_hPal, false);
RealizePalette (hDC);
}
// device dependent bitmap (DDB) erzeugen
hBM = CreateDIBitmap (hDC, lpBI, (long)CBM_INIT,
(char *)lpBI + lpBI->biSize +
DIBNumColors(lpBI)*sizeof(RGBQUAD), // PaletteSize (lpBI),
(BITMAPINFO *)lpBI, DIB_RGB_COLORS);
// alte Palette wiedereinstellen
if (m_hPal)
SelectPalette (hDC, hPalT, false);
ReleaseDC (NULL, hDC);
GlobalUnlock (m_hDIB);
return hBM;
}
示例9: khui_create_ilist
KHMEXP khui_ilist * KHMAPI
khui_create_ilist(int cx, int cy, int n, int ng, int opt) {
BITMAPV5HEADER head;
HDC hdc;
khui_ilist * il = PMALLOC(sizeof(khui_ilist));
il->cx = cx;
il->cy = cy;
il->n = n;
il->ng = ng;
il->nused = 0;
hdc = GetDC(NULL);
head.bV5Size = sizeof(head);
head.bV5Width = cx * n;
head.bV5Height = cy;
head.bV5Planes = 1;
head.bV5BitCount = 24;
head.bV5Compression = BI_RGB;
head.bV5SizeImage = 0;
head.bV5XPelsPerMeter = 2835;
head.bV5YPelsPerMeter = 2835;
head.bV5ClrUsed = 0;
head.bV5ClrImportant = 0;
head.bV5AlphaMask = 0;
head.bV5CSType = LCS_WINDOWS_COLOR_SPACE;
head.bV5Intent = LCS_GM_GRAPHICS;
head.bV5ProfileData = 0;
head.bV5ProfileSize = 0;
head.bV5Reserved = 0;
il->img = CreateDIBitmap(hdc, (BITMAPINFOHEADER *) &head, 0, NULL, NULL, DIB_RGB_COLORS);
il->mask = CreateBitmap(cx * n, cy, 1, 1, NULL);
il->idlist = PMALLOC(sizeof(int) * n);
return il;
}
示例10: sizeof
HBITMAP CImageFile::LoadFromMemory(LPCVOID pBuffer, DWORD nLength, HDC hUseDC)
{
LPSTR hDIB;
LPVOID lpDIBBits;
BITMAPFILEHEADER bmfHeader;
DWORD bmfHeaderLen;
bmfHeaderLen = sizeof(bmfHeader);
strncpy( (LPSTR)&bmfHeader, (LPSTR)pBuffer, bmfHeaderLen );
if ( bmfHeader.bfType != ((WORD) ('M' << 8) | 'B') ) return NULL;
hDIB = (LPSTR)pBuffer + bmfHeaderLen;
BITMAPINFOHEADER &bmiHeader = *(LPBITMAPINFOHEADER)hDIB ;
BITMAPINFO &bmInfo = *(LPBITMAPINFO)hDIB ;
int nColors = bmiHeader.biClrUsed ? bmiHeader.biClrUsed : 1 << bmiHeader.biBitCount;
if ( bmInfo.bmiHeader.biBitCount > 8 )
lpDIBBits = (LPVOID)((LPDWORD)(bmInfo.bmiColors + bmInfo.bmiHeader.biClrUsed) +
((bmInfo.bmiHeader.biCompression == BI_BITFIELDS) ? 3 : 0));
else
lpDIBBits = (LPVOID)(bmInfo.bmiColors + nColors);
HDC hDC = hUseDC ? hUseDC : GetDC( 0 );
return CreateDIBitmap( hDC, &bmiHeader, CBM_INIT, lpDIBBits, &bmInfo, DIB_RGB_COLORS );
}
示例11: GetProcAddress
// ---------------------------------------------------------------------------
//
HBITMAP __fastcall TForm1::SPI_LoadImage(String fileName) {
/* 対応プラグインの検索 */
for (int i = 0; i < hSPI->Count; i++) { // プラグイン関数の取得
SPI_ISSUPPORTED spi_issupported = (SPI_ISSUPPORTED) GetProcAddress((HMODULE) hSPI->Items[i], SPIPROC_ISSUPPORTED);
SPI_GETPICTURE spi_getpicture = (SPI_GETPICTURE) GetProcAddress((HMODULE) hSPI->Items[i], SPIPROC_GETPICTURE);
if (spi_issupported == NULL || spi_getpicture == NULL) {
continue;
}
// File内容をロードする
HANDLE handle; // = NULL;
if ((handle = CreateFile_Read(fileName.w_str())) == INVALID_HANDLE_VALUE) {
return NULL;
}
DWORD filesize = GetFileSize(handle, NULL), readsize;
LPSTR data = (LPSTR) Heap_Malloc(filesize);
SetFilePointer(handle, 0, NULL, FILE_BEGIN);
if (!ReadFile(handle, data, filesize, &readsize, NULL)) {
CloseHandle(handle);
}
CloseHandle(handle);
// ロードできる形式かどうかをチェックする
if (spi_issupported(AnsiString(fileName).c_str(), (DWORD) data) == 0) {
Heap_Free(data);
continue;
}
// 画像を展開する
HLOCAL info, bm;
if (spi_getpicture(data, filesize, 1, &info, &bm, NULL, 0) != 0) {
Heap_Free(data);
}
LPBITMAPINFO bmpinfo = (LPBITMAPINFO) LocalLock(info); // BITMAPINFO構造体
LPBYTE bmbits = (LPBYTE) LocalLock(bm); // 画像データ
// 取得した情報からBITMAPハンドルを生成する
HDC dc = GetDC(0);
HBITMAP bitmap = CreateDIBitmap(dc, &bmpinfo->bmiHeader, CBM_INIT, bmbits, bmpinfo, DIB_RGB_COLORS);
ReleaseDC(0, dc);
// Free etc...
LocalUnlock(info);
LocalFree(info);
LocalUnlock(bm);
LocalFree(bm);
Heap_Free(data);
return bitmap;
}
return NULL;
}
示例12: LoadAlterBitmap
STATICFN HBITMAP LoadAlterBitmap(
INT idbm,
DWORD rgbNew,
DWORD rgbNew2)
{
register INT i;
LPBITMAPINFOHEADER lpbihInfo;
HDC hdcScreen;
HANDLE hresLoad;
DWORD FAR *qlng;
LPBYTE lpbBits;
HANDLE hbmp;
DWORD rgbReplace1;
DWORD rgbReplace2;
hresLoad = FindResource(ghInst, MAKEINTRESOURCE(idbm), RT_BITMAP);
if (!hresLoad)
return NULL;
lpbihInfo = (LPBITMAPINFOHEADER)CloneResource(ghInst, hresLoad);
if (lpbihInfo == NULL)
return NULL;
rgbNew = RGBInvertRGB(rgbNew);
rgbNew2 = RGBInvertRGB(rgbNew2);
rgbReplace1 = RGBInvertRGB(REPLACECOLOR1);
rgbReplace2 = RGBInvertRGB(REPLACECOLOR2);
qlng = (LPDWORD)((PBYTE)(lpbihInfo) + lpbihInfo->biSize);
for (i = 0; i < (1 << lpbihInfo->biBitCount); i++, qlng++) {
if (*qlng == rgbReplace1)
*qlng = rgbNew;
else if (*qlng == rgbReplace2)
*qlng = rgbNew2;
}
/*
* First skip over the header structure.
*/
lpbBits = (LPBYTE)(lpbihInfo + 1);
/*
* Skip the color table entries, if any.
*/
lpbBits += (1 << (lpbihInfo->biBitCount)) * sizeof(RGBQUAD);
/*
* Create a color bitmap compatible with the display device.
*/
if (hdcScreen = GetDC(NULL)) {
hbmp = CreateDIBitmap(hdcScreen, lpbihInfo, (LONG)CBM_INIT,
lpbBits, (LPBITMAPINFO)lpbihInfo, DIB_RGB_COLORS);
ReleaseDC(NULL, hdcScreen);
}
LocalFree(lpbihInfo);
return hbmp;
}
示例13: CreateBitmapObjectFromDibFile
HBITMAP CreateBitmapObjectFromDibFile (HDC hdc, PTSTR szFileName)
{
BITMAPFILEHEADER * pbmfh ;
BOOL bSuccess ;
DWORD dwFileSize, dwHighSize, dwBytesRead ;
HANDLE hFile ;
HBITMAP hBitmap ;
// Open the file: read access, prohibit write access
hFile = CreateFile (szFileName, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL) ;
if (hFile == INVALID_HANDLE_VALUE)
return NULL ;
// Read in the whole file
dwFileSize = GetFileSize (hFile, &dwHighSize) ;
if (dwHighSize)
{
CloseHandle (hFile) ;
return NULL ;
}
pbmfh = malloc (dwFileSize) ;
if (!pbmfh)
{
CloseHandle (hFile) ;
return NULL ;
}
bSuccess = ReadFile (hFile, pbmfh, dwFileSize, &dwBytesRead, NULL) ;
CloseHandle (hFile) ;
// Verify the file
if (!bSuccess || (dwBytesRead != dwFileSize)
|| (pbmfh->bfType != * (WORD *) "BM")
|| (pbmfh->bfSize != dwFileSize))
{
free (pbmfh) ;
return NULL ;
}
// Create the DDB
hBitmap = CreateDIBitmap (hdc,
(BITMAPINFOHEADER *) (pbmfh + 1),
CBM_INIT,
(BYTE *) pbmfh + pbmfh->bfOffBits,
(BITMAPINFO *) (pbmfh + 1),
DIB_RGB_COLORS) ;
free (pbmfh) ;
return hBitmap ;
}
示例14: GetBitmapInfo
HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC)
{
CFX_ByteString info = GetBitmapInfo(pBitmap);
HBITMAP hBitmap = NULL;
hBitmap = CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT,
pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS);
return hBitmap;
}
示例15: CreateDIBitmap
HBITMAP CDib::GetHBITMAP(HDC hdc)
{
if(m_valid)
return CreateDIBitmap(hdc,m_pBitmapInfoHeader,
CBM_INIT,(VOID *)m_pData,m_pBitmapInfo, DIB_RGB_COLORS);
else
return NULL;
}