本文整理汇总了C++中GetPixelFormat函数的典型用法代码示例。如果您正苦于以下问题:C++ GetPixelFormat函数的具体用法?C++ GetPixelFormat怎么用?C++ GetPixelFormat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetPixelFormat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dibdrv_wglMakeCurrent
/***********************************************************************
* dibdrv_wglMakeCurrent
*/
static BOOL dibdrv_wglMakeCurrent( HDC hdc, struct wgl_context *context )
{
HBITMAP bitmap;
BITMAPOBJ *bmp;
dib_info dib;
GLenum type;
BOOL ret = FALSE;
if (!context)
{
pOSMesaMakeCurrent( NULL, NULL, GL_UNSIGNED_BYTE, 0, 0 );
return TRUE;
}
if (GetPixelFormat( hdc ) != context->format)
FIXME( "mismatched pixel formats %u/%u not supported yet\n",
GetPixelFormat( hdc ), context->format );
bitmap = GetCurrentObject( hdc, OBJ_BITMAP );
bmp = GDI_GetObjPtr( bitmap, OBJ_BITMAP );
if (!bmp) return FALSE;
if (init_dib_info_from_bitmapobj( &dib, bmp ))
{
char *bits;
int width = dib.rect.right - dib.rect.left;
int height = dib.rect.bottom - dib.rect.top;
if (dib.stride < 0)
bits = (char *)dib.bits.ptr + (dib.rect.bottom - 1) * dib.stride;
else
bits = (char *)dib.bits.ptr + dib.rect.top * dib.stride;
bits += dib.rect.left * dib.bit_count / 8;
TRACE( "context %p bits %p size %ux%u\n", context, bits, width, height );
if (pixel_formats[context->format - 1].mesa == OSMESA_RGB_565)
type = GL_UNSIGNED_SHORT_5_6_5;
else
type = GL_UNSIGNED_BYTE;
ret = pOSMesaMakeCurrent( context->context, bits, type, width, height );
if (ret)
{
pOSMesaPixelStore( OSMESA_ROW_LENGTH, abs( dib.stride ) * 8 / dib.bit_count );
pOSMesaPixelStore( OSMESA_Y_UP, 1 ); /* Windows seems to assume bottom-up */
}
}
GDI_ReleaseObj( bitmap );
return ret;
}
示例2: GetPixelFormat
void Image::InsertImage(const Image* image, uint32 dstX, uint32 dstY,
uint32 srcX /* = 0 */, uint32 srcY /* = 0 */,
uint32 srcWidth /* = -1 */, uint32 srcHeight /* = -1 */)
{
if (GetPixelFormat() != image->GetPixelFormat())
{
return;
}
if (image == NULL || dstX >= width || dstY >= height ||
srcX >= image->GetWidth() || srcY >= image->GetHeight())
{
return;
}
uint32 insertWidth = (srcWidth == (uint32)-1) ? image->GetWidth() : srcWidth;
uint32 insertHeight = (srcHeight == (uint32)-1) ? image->GetHeight() : srcHeight;
if (srcX + insertWidth > image->GetWidth())
{
insertWidth = image->GetWidth() - srcX;
}
if (dstX + insertWidth > width)
{
insertWidth = width - dstX;
}
if (srcY + insertHeight > image->GetHeight())
{
insertHeight = image->GetHeight() - srcY;
}
if (dstY + insertHeight > height)
{
insertHeight = height - dstY;
}
PixelFormat format = GetPixelFormat();
int32 formatSize = PixelFormatDescriptor::GetPixelFormatSizeInBytes(format);
uint8* srcData = image->GetData();
uint8* dstData = data;
for (uint32 i = 0; i < insertHeight; ++i)
{
memcpy(dstData + (width * (dstY + i) + dstX) * formatSize,
srcData + (image->GetWidth() * (srcY + i) + srcX) * formatSize,
formatSize * insertWidth);
}
}
示例3: createDeviceEx
void CIrrWindow::createIrrDevice()
{
// create irr device
SIrrlichtCreationParameters param;
param.WindowId = (void*)getHandle();
param.ZBufferBits = 32;
param.DriverType = video::EDT_OPENGL;
m_device = createDeviceEx(param);
m_driver = m_device->getVideoDriver();
m_smgr = m_device->getSceneManager();
// init opengl
HDC HDc = GetDC( getHandle() );
PIXELFORMATDESCRIPTOR pfd={0};
pfd.nSize=sizeof(PIXELFORMATDESCRIPTOR);
int pf = GetPixelFormat(HDc);
DescribePixelFormat(HDc, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
pfd.dwFlags |= PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
pfd.cDepthBits=16;
pf = ChoosePixelFormat(HDc, &pfd);
SetPixelFormat(HDc, pf, &pfd);
// share video data
m_videoData.OpenGLWin32.HWnd = NULL;
m_videoData.OpenGLWin32.HDc = HDc;
m_videoData.OpenGLWin32.HRc = wglCreateContext(HDc);
// share for multithread
wglShareLists((HGLRC)m_driver->getExposedVideoData().OpenGLWin32.HRc, (HGLRC)m_videoData.OpenGLWin32.HRc);
g_irrView = this;
initScene();
}
示例4: getInternalFormat
static GLint getInternalFormat(void)
{
switch (glctx.type) {
#ifdef CONFIG_GL_WIN32
case GLTYPE_W32:
{
PIXELFORMATDESCRIPTOR pfd;
HDC vo_hdc = vo_w32_get_dc(vo_w32_window);
int pf = GetPixelFormat(vo_hdc);
if (!DescribePixelFormat(vo_hdc, pf, sizeof pfd, &pfd)) {
r_sz = g_sz = b_sz = a_sz = 0;
} else {
r_sz = pfd.cRedBits;
g_sz = pfd.cGreenBits;
b_sz = pfd.cBlueBits;
a_sz = pfd.cAlphaBits;
}
vo_w32_release_dc(vo_w32_window, vo_hdc);
}
break;
#endif
#ifdef CONFIG_GL_X11
case GLTYPE_X11:
if (glXGetConfig(mDisplay, glctx.vinfo.x11, GLX_RED_SIZE, &r_sz) != 0) r_sz = 0;
if (glXGetConfig(mDisplay, glctx.vinfo.x11, GLX_GREEN_SIZE, &g_sz) != 0) g_sz = 0;
if (glXGetConfig(mDisplay, glctx.vinfo.x11, GLX_BLUE_SIZE, &b_sz) != 0) b_sz = 0;
if (glXGetConfig(mDisplay, glctx.vinfo.x11, GLX_ALPHA_SIZE, &a_sz) != 0) a_sz = 0;
break;
#endif
}
rgb_sz=r_sz+g_sz+b_sz;
if(rgb_sz<=0) rgb_sz=24;
#ifdef TEXTUREFORMAT_ALWAYS
return TEXTUREFORMAT_ALWAYS;
#else
if(r_sz==3 && g_sz==3 && b_sz==2 && a_sz==0)
return GL_R3_G3_B2;
if(r_sz==4 && g_sz==4 && b_sz==4 && a_sz==0)
return GL_RGB4;
if(r_sz==5 && g_sz==5 && b_sz==5 && a_sz==0)
return GL_RGB5;
if(r_sz==8 && g_sz==8 && b_sz==8 && a_sz==0)
return GL_RGB8;
if(r_sz==10 && g_sz==10 && b_sz==10 && a_sz==0)
return GL_RGB10;
if(r_sz==2 && g_sz==2 && b_sz==2 && a_sz==2)
return GL_RGBA2;
if(r_sz==4 && g_sz==4 && b_sz==4 && a_sz==4)
return GL_RGBA4;
if(r_sz==5 && g_sz==5 && b_sz==5 && a_sz==1)
return GL_RGB5_A1;
if(r_sz==8 && g_sz==8 && b_sz==8 && a_sz==8)
return GL_RGBA8;
if(r_sz==10 && g_sz==10 && b_sz==10 && a_sz==2)
return GL_RGB10_A2;
#endif
return GL_RGB;
}
示例5: GetScreenWidth
//
// 지정된영역의 백버퍼데이타를 읽어서 surface에 옮긴다.
// GL은 프론트만 읽을수 있는줄알았는데 반대였다. 백버퍼만 읽을수 있다
// w,y,width,height: 스크린 좌표
void XGraphicsOpenGL::ScreenToSurface( int x, int y, int width, int height, XSurface *pSurface )
{
if( GetPixelFormat() != xPIXELFORMAT_RGB565 )
XERROR( "아직은 RGB565포맷만 사용가능함." );
int px, py, pw, ph; // 물리적스크린크기와 좌표.
float fRatioX, fRatioY;
// phyScreen과 screen의 비율로 좌표들을 변환.
fRatioX = (float)GetPhyScreenWidth() / GetScreenWidth();
fRatioY = (float)GetPhyScreenHeight() / GetScreenHeight();
px = x * fRatioX; py = y * fRatioY; // screen->physcreen 좌표로 변환
pw = width * fRatioX; ph = height * fRatioY;
//GL_NO_ERROR
DWORD *pdwBuffer = new DWORD[ pw * ph ];
glReadPixels(px, py, pw, ph, GL_RGBA, GL_UNSIGNED_BYTE, pdwBuffer ); // 위아래 뒤집혀진 이미지
DWORD *pDst = new DWORD[ pw * ph ];
// 위아래를 바꿈
for( int i = 0; i < ph; i ++ )
for( int j = 0; j < pw; j ++ )
pDst[ i * pw + j ] = pdwBuffer[ (ph-1-i) * pw + j ];
SAFE_DELETE_ARRAY( pdwBuffer );
pSurface->Create( pw, ph, 0, 0, xALPHA, pDst, sizeof(DWORD), 0, 0 );
#pragma messages( "pdwBuffer를 XSurfaceOpenGL::Create()내부에서 뽀개주도록 바꿔야 한다. 버그날까봐 일단 이상태로 놔둠" )
}
示例6: ComputeVisBits
/**
* Compute a mask of CR_*_BIT flags which reflects the attributes of
* the pixel format of the given hdc.
*/
static GLuint ComputeVisBits( HDC hdc )
{
PIXELFORMATDESCRIPTOR pfd;
int iPixelFormat;
GLuint b = 0;
iPixelFormat = GetPixelFormat( hdc );
DescribePixelFormat( hdc, iPixelFormat, sizeof(pfd), &pfd );
if (pfd.cDepthBits > 0)
b |= CR_DEPTH_BIT;
if (pfd.cAccumBits > 0)
b |= CR_ACCUM_BIT;
if (pfd.cColorBits > 8)
b |= CR_RGB_BIT;
if (pfd.cStencilBits > 0)
b |= CR_STENCIL_BIT;
if (pfd.cAlphaBits > 0)
b |= CR_ALPHA_BIT;
if (pfd.dwFlags & PFD_DOUBLEBUFFER)
b |= CR_DOUBLE_BIT;
if (pfd.dwFlags & PFD_STEREO)
b |= CR_STEREO_BIT;
return b;
}
示例7: av_frame_alloc
HRESULT CDecD3D11::DeliverD3D11Readback(LAVFrame *pFrame)
{
AVFrame *src = (AVFrame *)pFrame->priv_data;
AVFrame *dst = av_frame_alloc();
int ret = av_hwframe_transfer_data(dst, src, 0);
if (ret < 0)
{
ReleaseFrame(&pFrame);
av_frame_free(&dst);
return E_FAIL;
}
// free the source frame
av_frame_free(&src);
// and store the dst frame in LAVFrame
pFrame->priv_data = dst;
GetPixelFormat(&pFrame->format, &pFrame->bpp);
ASSERT((dst->format == AV_PIX_FMT_NV12 && pFrame->format == LAVPixFmt_NV12) || (dst->format == AV_PIX_FMT_P010 && pFrame->format == LAVPixFmt_P016));
for (int i = 0; i < 4; i++) {
pFrame->data[i] = dst->data[i];
pFrame->stride[i] = dst->linesize[i];
}
return Deliver(pFrame);
}
示例8: YsCreatePalette
static HPALETTE YsCreatePalette(HDC dc)
{
HPALETTE neo;
PIXELFORMATDESCRIPTOR pfd;
LOGPALETTE *lp;
int n,i;
n=GetPixelFormat(dc);
DescribePixelFormat(dc,n,sizeof(PIXELFORMATDESCRIPTOR),&pfd);
if(pfd.dwFlags & PFD_NEED_PALETTE)
{
n=1<<pfd.cColorBits;
lp=(LOGPALETTE *)malloc(sizeof(LOGPALETTE)+n*sizeof(PALETTEENTRY));
lp->palVersion=0x300;
lp->palNumEntries=(WORD)n;
for (i=0; i<n; i++)
{
lp->palPalEntry[i].peRed =YsPalVal(i,pfd.cRedBits,pfd.cRedShift);
lp->palPalEntry[i].peGreen=YsPalVal(i,pfd.cGreenBits,pfd.cGreenShift);
lp->palPalEntry[i].peBlue =YsPalVal(i,pfd.cBlueBits,pfd.cBlueShift);
lp->palPalEntry[i].peFlags=0;
}
neo=CreatePalette(lp);
free(lp);
return neo;
}
return NULL;
}
示例9: SetMemAlign
void Image::Draw(float x, float y) const
{
if(!m_uWidth)
return;
SetMemAlign(m_uWidth, FALSE);
glRasterPos2f(x, y);
glDrawPixels(m_uWidth, m_uHeight, GetPixelFormat(), GL_UNSIGNED_BYTE, GetDataPtr());
}
示例10: GetSizeX
FString UTextureCube::GetDesc()
{
return FString::Printf(TEXT("Cube: %dx%d [%s]"),
GetSizeX(),
GetSizeY(),
GPixelFormats[GetPixelFormat()].Name
);
}
示例11: WGL_NATIVE
JNIEXPORT jint JNICALL WGL_NATIVE(GetPixelFormat)
(JNIEnv *env, jclass that, jintLong arg0)
{
jint rc = 0;
WGL_NATIVE_ENTER(env, that, GetPixelFormat_FUNC);
rc = (jint)GetPixelFormat((HDC)arg0);
WGL_NATIVE_EXIT(env, that, GetPixelFormat_FUNC);
return rc;
}
示例12: GetDepth
int wxIDirectFBSurface::GetDepth()
{
DFBSurfacePixelFormat format = DSPF_UNKNOWN;
if ( !GetPixelFormat(&format) )
return -1;
return DFB_BITS_PER_PIXEL(format);
}
示例13:
// 백버퍼의 픽셀을 읽어서 pBuffer에 담아줌.
// m_nWidth는 논리적서피스의 크기이고 work와 같고, back,frame 버퍼는 실제물리적 해상도인것으로 구분해줄 필요 있다.
void* XGraphicsOpenGL::ReadBackBuffer( int phywidth, int phyheight, void *pBuffer )
{
if( GetPixelFormat() != xPIXELFORMAT_RGB565 )
XERROR( "아직은 RGB565포맷만 사용가능함." );
// glReadBufferOES( GL_BACK ); // gl1.2 ES엔 없는듯.
// gl1.x에선 프론트가 아니고 백버퍼만 읽을수 있는듯 하다. 잘못알고 있었음-_-;;
glReadPixels(0, 0, phywidth, phyheight, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pBuffer );
return pBuffer;
}
示例14: DrvCreateLayerContext
DHGLRC APIENTRY
DrvCreateLayerContext(
HDC hdc,
INT iLayerPlane )
{
int iPixelFormat;
const struct stw_pixelformat_info *pfi;
struct st_context_attribs attribs;
struct stw_context *ctx = NULL;
if(!stw_dev)
return 0;
if (iLayerPlane != 0)
return 0;
iPixelFormat = GetPixelFormat(hdc);
if(!iPixelFormat)
return 0;
pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
ctx = CALLOC_STRUCT( stw_context );
if (ctx == NULL)
goto no_ctx;
ctx->hdc = hdc;
ctx->iPixelFormat = iPixelFormat;
memset(&attribs, 0, sizeof(attribs));
attribs.profile = ST_PROFILE_DEFAULT;
attribs.visual = pfi->stvis;
ctx->st = stw_dev->stapi->create_context(stw_dev->stapi,
stw_dev->smapi, &attribs, NULL);
if (ctx->st == NULL)
goto no_st_ctx;
ctx->st->st_manager_private = (void *) ctx;
pipe_mutex_lock( stw_dev->ctx_mutex );
ctx->dhglrc = handle_table_add(stw_dev->ctx_table, ctx);
pipe_mutex_unlock( stw_dev->ctx_mutex );
if (!ctx->dhglrc)
goto no_hglrc;
return ctx->dhglrc;
no_hglrc:
ctx->st->destroy(ctx->st);
no_st_ctx:
FREE(ctx);
no_ctx:
return 0;
}
示例15: XCreateColormap
Colormap
XCreateColormap(Display* display, Window root, Visual* visual, int alloc)
{
/* KLUDGE: this function needs XHDC to be set to the HDC currently
being operated on before it is invoked! */
PIXELFORMATDESCRIPTOR pfd;
LOGPALETTE *logical;
HPALETTE palette;
int n;
/* grab the pixel format */
memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
DescribePixelFormat(XHDC, GetPixelFormat(XHDC),
sizeof(PIXELFORMATDESCRIPTOR), &pfd);
if (!(pfd.dwFlags & PFD_NEED_PALETTE ||
pfd.iPixelType == PFD_TYPE_COLORINDEX))
{
return 0;
}
n = 1 << pfd.cColorBits;
/* allocate a bunch of memory for the logical palette (assume 256
colors in a Win32 palette */
logical = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) +
sizeof(PALETTEENTRY) * n);
memset(logical, 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * n);
/* set the entries in the logical palette */
logical->palVersion = 0x300;
logical->palNumEntries = n;
/* start with a copy of the current system palette */
GetSystemPaletteEntries(XHDC, 0, 256, &logical->palPalEntry[0]);
if (pfd.iPixelType == PFD_TYPE_RGBA) {
int redMask = (1 << pfd.cRedBits) - 1;
int greenMask = (1 << pfd.cGreenBits) - 1;
int blueMask = (1 << pfd.cBlueBits) - 1;
int i;
/* fill in an RGBA color palette */
for (i = 0; i < n; ++i) {
logical->palPalEntry[i].peRed =
(((i >> pfd.cRedShift) & redMask) * 255) / redMask;
logical->palPalEntry[i].peGreen =
(((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask;
logical->palPalEntry[i].peBlue =
(((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask;
logical->palPalEntry[i].peFlags = 0;
}
}