HRESULT STDMETHODCALLTYPE CVCamStream::GetStreamCaps(int iIndex, AM_MEDIA_TYPE **pmt, BYTE *pSCC) { *pmt = CreateMediaType(&m_mt); DECLARE_PTR(VIDEOINFOHEADER, pvi, (*pmt)->pbFormat); // if (iIndex == 0) iIndex = 4; if (iIndex == 0) iIndex = 8; pvi->bmiHeader.biCompression = BI_RGB; pvi->bmiHeader.biBitCount = 24; pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pvi->bmiHeader.biWidth = 80 * iIndex; pvi->bmiHeader.biHeight = 60 * iIndex; pvi->bmiHeader.biPlanes = 1; pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader); pvi->bmiHeader.biClrImportant = 0; SetRectEmpty(&(pvi->rcSource)); // we want the whole image area rendered. SetRectEmpty(&(pvi->rcTarget)); // no particular destination rectangle (*pmt)->majortype = MEDIATYPE_Video; (*pmt)->subtype = MEDIASUBTYPE_RGB24; (*pmt)->formattype = FORMAT_VideoInfo; (*pmt)->bTemporalCompression = FALSE; (*pmt)->bFixedSizeSamples= FALSE; (*pmt)->lSampleSize = pvi->bmiHeader.biSizeImage; (*pmt)->cbFormat = sizeof(VIDEOINFOHEADER); DECLARE_PTR(VIDEO_STREAM_CONFIG_CAPS, pvscc, pSCC); pvscc->guid = FORMAT_VideoInfo; pvscc->VideoStandard = AnalogVideo_None; pvscc->InputSize.cx = 640; pvscc->InputSize.cy = 480; pvscc->MinCroppingSize.cx = 80; pvscc->MinCroppingSize.cy = 60; pvscc->MaxCroppingSize.cx = 640; pvscc->MaxCroppingSize.cy = 480; pvscc->CropGranularityX = 80; pvscc->CropGranularityY = 60; pvscc->CropAlignX = 0; pvscc->CropAlignY = 0; pvscc->MinOutputSize.cx = 80; pvscc->MinOutputSize.cy = 60; pvscc->MaxOutputSize.cx = 640; pvscc->MaxOutputSize.cy = 480; pvscc->OutputGranularityX = 0; pvscc->OutputGranularityY = 0; pvscc->StretchTapsX = 0; pvscc->StretchTapsY = 0; pvscc->ShrinkTapsX = 0; pvscc->ShrinkTapsY = 0; pvscc->MinFrameInterval = 200000; //50 fps pvscc->MaxFrameInterval = 50000000; // 0.2 fps pvscc->MinBitsPerSecond = (80 * 60 * 3 * 8) / 5; pvscc->MaxBitsPerSecond = 640 * 480 * 3 * 8 * 50; return S_OK; }
CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) { CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); if (pPlatform->m_GdiplusExt.IsAvailable()) { return pPlatform->m_GdiplusExt.LoadDIBitmap(args); } else if (args.flags == WINDIB_OPEN_MEMORY) { return NULL; } HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)args.path_name, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); if (hBitmap == NULL) { return NULL; } HDC hDC = CreateCompatibleDC(NULL); int width, height; GetBitmapSize(hBitmap, width, height); CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { delete pDIBitmap; DeleteDC(hDC); return NULL; } CFX_ByteString info = GetBitmapInfo(pDIBitmap); int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); if (!ret) { delete pDIBitmap; pDIBitmap = NULL; } DeleteDC(hDC); return pDIBitmap; }
// create data for a .bmp file from this bitmap (if saved to disk, the HBITMAP // can be deserialized with LoadImage(NULL, ..., LD_LOADFROMFILE) and its // dimensions determined again with GetBitmapSize(...)) unsigned char *SerializeBitmap(HBITMAP hbmp, size_t *bmpBytesOut) { SizeI size = GetBitmapSize(hbmp); DWORD bmpHeaderLen = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFO); DWORD bmpBytes = ((size.dx * 3 + 3) / 4) * 4 * size.dy + bmpHeaderLen; unsigned char *bmpData = AllocArray<unsigned char>(bmpBytes); if (!bmpData) return NULL; BITMAPINFO *bmi = (BITMAPINFO *)(bmpData + sizeof(BITMAPFILEHEADER)); bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader); bmi->bmiHeader.biWidth = size.dx; bmi->bmiHeader.biHeight = size.dy; bmi->bmiHeader.biPlanes = 1; bmi->bmiHeader.biBitCount = 24; bmi->bmiHeader.biCompression = BI_RGB; HDC hDC = GetDC(NULL); if (GetDIBits(hDC, hbmp, 0, size.dy, bmpData + bmpHeaderLen, bmi, DIB_RGB_COLORS)) { BITMAPFILEHEADER *bmpfh = (BITMAPFILEHEADER *)bmpData; bmpfh->bfType = MAKEWORD('B', 'M'); bmpfh->bfOffBits = bmpHeaderLen; bmpfh->bfSize = bmpBytes; } else { free(bmpData); bmpData = NULL; } ReleaseDC(NULL, hDC); if (bmpBytesOut) *bmpBytesOut = bmpBytes; return bmpData; }
HRESULT videoSource::GetMediaType(int iPosition, CMediaType *pmt) { CAutoLock cAutoLock(m_pFilter->pStateLock()); if (iPosition < 0) return E_INVALIDARG; if (iPosition > 0) return VFW_S_NO_MORE_ITEMS; VIDEOINFO *pvi = (VIDEOINFO*) pmt->AllocFormatBuffer(sizeof(VIDEOINFO)); if (NULL == pvi) return(E_OUTOFMEMORY); ZeroMemory(pvi, sizeof(VIDEOINFO)); pvi->bmiHeader.biCompression = BI_RGB; pvi->bmiHeader.biBitCount = 24; pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pvi->bmiHeader.biWidth = width; pvi->bmiHeader.biHeight = height; pvi->bmiHeader.biPlanes = 1; pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader); pvi->bmiHeader.biClrImportant = 0; scanwidth = pvi->bmiHeader.biSizeImage/3/height; SetRectEmpty(&(pvi->rcSource)); // we want the whole image area rendered. SetRectEmpty(&(pvi->rcTarget)); // no particular destination rectangle pmt->SetType(&MEDIATYPE_Video); pmt->SetFormatType(&FORMAT_VideoInfo); pmt->SetTemporalCompression(FALSE); pmt->SetSubtype(&MEDIASUBTYPE_RGB24); pmt->SetSampleSize(pvi->bmiHeader.biSizeImage); return NOERROR; }
// LJ version for one media type // // GetMediaType: This method tells the downstream pin what types we support. // // Here is how CSourceStream deals with media types: // // If you support exactly one type, override GetMediaType(CMediaType*). It will then be // called when // (a) our filter proposes a media type, // (b) the other filter proposes a type and we have to check that type. // // If you support > 1 type, override GetMediaType(int,CMediaType*) AND CheckMediaType. // // In this case we support only one type, which we obtain from the bitmap. // // Can be called repeatedly // HRESULT CVCamStream::GetMediaType(CMediaType *pmt) { unsigned int width, height; if(pmt == NULL) { return E_POINTER; } DECLARE_PTR(VIDEOINFOHEADER, pvi, pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER))); ZeroMemory(pvi, sizeof(VIDEOINFOHEADER)); // Allow for default as well as width and height of memory share image if(g_Width == 0 || g_Height == 0) { width = 320; height = 240; } else { // as per sending app width = g_Width; height = g_Height; } pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pvi->bmiHeader.biWidth = (LONG)width; pvi->bmiHeader.biHeight = (LONG)height; pvi->bmiHeader.biPlanes = 1; pvi->bmiHeader.biBitCount = 24; pvi->bmiHeader.biCompression = 0; pvi->bmiHeader.biSizeImage = 0; // default // pvi->bmiHeader.biXPelsPerMeter = 0; // default // pvi->bmiHeader.biYPelsPerMeter = 0; // default // pvi->bmiHeader.biClrUsed = 0; pvi->bmiHeader.biClrImportant = 0; pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader); // The desired average display time of the video frames, in 100-nanosecond units. // 60fps = 166667 // 30fps = 333333 pvi->AvgTimePerFrame = 166667; // 60fps // pvi->AvgTimePerFrame = 200000; // 50fps // pvi->AvgTimePerFrame = 333333; // 30fps SetRectEmpty(&(pvi->rcSource)); // we want the whole image area rendered. SetRectEmpty(&(pvi->rcTarget)); // no particular destination rectangle pmt->SetType(&MEDIATYPE_Video); pmt->SetFormatType(&FORMAT_VideoInfo); pmt->SetTemporalCompression(false); // Work out the GUID for the subtype from the header info. const GUID SubTypeGUID = GetBitmapSubtype(&pvi->bmiHeader); pmt->SetSubtype(&SubTypeGUID); pmt->SetVariableSize(); // LJ - to be checked pmt->SetSampleSize(pvi->bmiHeader.biSizeImage); return NOERROR; }
void CPushPinDesktop::CopyScreenToDataBlock(HDC hScrDC, BYTE *pData, BITMAPINFO *pHeader, IMediaSample *pSample) { HDC hMemDC; // screen DC and memory DC HBITMAP hOldBitmap; // handles to device-dependent bitmaps int nX, nY; // coordinates of rectangle to grab int iFinalStretchHeight = getNegotiatedFinalHeight(); int iFinalStretchWidth = getNegotiatedFinalWidth(); ASSERT(!IsRectEmpty(&m_rScreen)); // that would be unexpected // create a DC for the screen and create // a memory DC compatible to screen DC hMemDC = CreateCompatibleDC(hScrDC); // 0.02ms Anything else to reuse, this one's pretty fast...? // determine points of where to grab from it, though I think we control these with m_rScreen nX = m_rScreen.left; nY = m_rScreen.top; // sanity checks--except we don't want it apparently, to allow upstream to dynamically change the size? Can it do that? ASSERT(m_rScreen.bottom - m_rScreen.top == iFinalStretchHeight); ASSERT(m_rScreen.right - m_rScreen.left == iFinalStretchWidth); // select new bitmap into memory DC hOldBitmap = (HBITMAP) SelectObject(hMemDC, hRawBitmap); doJustBitBltOrScaling(hMemDC, m_iCaptureConfigWidth, m_iCaptureConfigHeight, iFinalStretchWidth, iFinalStretchHeight, hScrDC, nX, nY); AddMouse(hMemDC, &m_rScreen, hScrDC, m_iHwndToTrack); // select old bitmap back into memory DC and get handle to // bitmap of the capture...whatever this even means... HBITMAP hRawBitmap2 = (HBITMAP) SelectObject(hMemDC, hOldBitmap); BITMAPINFO tweakableHeader; memcpy(&tweakableHeader, pHeader, sizeof(BITMAPINFO)); if(m_bConvertToI420) { tweakableHeader.bmiHeader.biBitCount = 32; tweakableHeader.bmiHeader.biCompression = BI_RGB; tweakableHeader.bmiHeader.biHeight = -tweakableHeader.bmiHeader.biHeight; // prevent upside down conversion from i420... tweakableHeader.bmiHeader.biSizeImage = GetBitmapSize(&tweakableHeader.bmiHeader); } if(m_bConvertToI420) { // copy it to a temporary buffer first doDIBits(hScrDC, hRawBitmap2, iFinalStretchHeight, pOldData, &tweakableHeader); // memcpy(/* dest */ pOldData, pData, pSample->GetSize()); // 12.8ms for 1920x1080 desktop // TODO smarter conversion/memcpy's here [?] we could combine scaling with rgb32_to_i420 for instance... // or maybe we should integrate with libswscale here so they can request whatever they want LOL. (might be a higher quality i420 conversion...) // now convert it to i420 into the "real" buffer rgb32_to_i420(iFinalStretchWidth, iFinalStretchHeight, (const char *) pOldData, (char *) pData);// took 36.8ms for 1920x1080 desktop } else { doDIBits(hScrDC, hRawBitmap2, iFinalStretchHeight, pData, &tweakableHeader); } // clean up DeleteDC(hMemDC); }
SIZE GetIconSize(HICON hIcon) { SIZE szSize = {0}; ICONINFO icoInfo = {0}; if (! ::GetIconInfo(hIcon, &icoInfo)) return szSize; return GetBitmapSize(icoInfo.hbmColor); };
HRESULT CCINVideoDecompressor::GetMediaType( int iPosition, CMediaType *pMediaType ) { CAutoLock lock(m_pLock); // Check and validate the pointer CheckPointer(pMediaType, E_POINTER); ValidateWritePtr(pMediaType, sizeof(CMediaType)); // At this time we should have the format block if (!m_pFormat) return E_UNEXPECTED; if (iPosition < 0) return E_INVALIDARG; else if (iPosition > 0) return VFW_S_NO_MORE_ITEMS; else { pMediaType->InitMediaType(); // Is it needed ??? // Allocate the video info block VIDEOINFO *pVideoInfo = (VIDEOINFO*)pMediaType->AllocFormatBuffer(sizeof(VIDEOINFO)); if (pVideoInfo == NULL) return E_OUTOFMEMORY; // Prepare the video info block ZeroMemory(pVideoInfo, sizeof(VIDEOINFO)); SetRectEmpty(&pVideoInfo->rcSource); SetRectEmpty(&pVideoInfo->rcTarget); pVideoInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pVideoInfo->bmiHeader.biWidth = (LONG)m_pFormat->dwVideoWidth; pVideoInfo->bmiHeader.biHeight = -(LONG)m_pFormat->dwVideoHeight; pVideoInfo->bmiHeader.biPlanes = 1; pVideoInfo->bmiHeader.biBitCount = 8; pVideoInfo->bmiHeader.biCompression = BI_RGB; pVideoInfo->bmiHeader.biSizeImage = GetBitmapSize(&pVideoInfo->bmiHeader); pVideoInfo->bmiHeader.biXPelsPerMeter = 0; pVideoInfo->bmiHeader.biYPelsPerMeter = 0; pVideoInfo->bmiHeader.biClrUsed = 256; pVideoInfo->bmiHeader.biClrImportant = 0; pVideoInfo->dwBitRate = pVideoInfo->bmiHeader.biSizeImage * 8 * CIN_FPS; pVideoInfo->dwBitErrorRate = 0; pVideoInfo->AvgTimePerFrame = UNITS / CIN_FPS; // Set media type fields pMediaType->SetType(&MEDIATYPE_Video); pMediaType->SetSubtype(&MEDIASUBTYPE_RGB8); pMediaType->SetSampleSize(pVideoInfo->bmiHeader.biSizeImage); pMediaType->SetTemporalCompression(FALSE); pMediaType->SetFormatType(&FORMAT_VideoInfo); } return S_OK; }
void CImageBkgTabCtrl::SetImgTabBtn(CImgTabBtn* pImgTabBtn, BOOL bAutoAdjustHeight) { m_pImgTabBtn = pImgTabBtn; if(bAutoAdjustHeight && m_pImgTabBtn->m_pTabPart[TB_PT_BACKGROUND] != NULL) { int height = GetBitmapSize(m_pImgTabBtn->m_pTabPart[TB_PT_BACKGROUND]).cy; SetTabItemHeight(height); } }
wxSize wxBitmapComboBox::DoGetBestSize() const { wxSize best = wxComboBox::DoGetBestSize(); int delta = GetBitmapSize().y - GetCharHeight(); if ( delta > 0 ) best.y += delta; return best; }
CSize GraphicsMisc::GetIconSize(HICON hIcon) { ICONINFO iconinfo = { 0 }; ::GetIconInfo(hIcon, &iconinfo); CSize sIcon = GetBitmapSize(iconinfo.hbmColor); // cleanup GraphicsMisc::VerifyDeleteObject(iconinfo.hbmColor); GraphicsMisc::VerifyDeleteObject(iconinfo.hbmMask); return sIcon; }
wxSize wxBitmapComboBox::DoGetBestSize() const { wxSize best = wxComboBox::DoGetBestSize(); wxSize bitmapSize = GetBitmapSize(); wxCoord useHeightBitmap = EDIT_HEIGHT_FROM_CHAR_HEIGHT(bitmapSize.y); if ( best.y < useHeightBitmap ) { best.y = useHeightBitmap; CacheBestSize(best); } return best; }
// See Directshow help topic for IAMStreamConfig for details on this method HRESULT CKCamStream::GetMediaType(int iPosition, CMediaType *pmt) { DbgLog((LOG_TRACE, 1, "GetMediaType (iPosition = %d)", iPosition)); if (!m_device) return E_FAIL; if (iPosition < 0) return E_INVALIDARG; if (iPosition > m_device->video_resolution_count()) return VFW_S_NO_MORE_ITEMS; if (iPosition == 0) { // return the default (preferred) resolution *pmt = m_mt; return S_OK; // exit !!! } // check the device for information of this resolution auto f_devres = m_device->video_resolution(iPosition - 1); // fill in the VIDEOINFO_HEADER DECLARE_PTR(VIDEOINFOHEADER, pvi, pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER))); ZeroMemory(pvi, sizeof(VIDEOINFOHEADER)); pvi->bmiHeader.biCompression = CompressionFromPixelFormat(f_devres.m_pixel_format); pvi->bmiHeader.biBitCount = f_devres.m_bits_per_pixel; pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pvi->bmiHeader.biWidth = f_devres.m_width; pvi->bmiHeader.biHeight = f_devres.m_height; pvi->bmiHeader.biPlanes = 1; pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader); pvi->bmiHeader.biClrImportant = 0; pvi->AvgTimePerFrame = FrameIntervalFromRate(f_devres.m_framerate); SetRectEmpty(&(pvi->rcSource)); // we want the whole image area rendered. SetRectEmpty(&(pvi->rcTarget)); // no particular destination rectangle pmt->SetType(&MEDIATYPE_Video); pmt->SetFormatType(&FORMAT_VideoInfo); pmt->SetTemporalCompression(FALSE); // Work out the GUID for the subtype from the header info. const GUID SubTypeGUID = GetBitmapSubtype(&pvi->bmiHeader); pmt->SetSubtype(&SubTypeGUID); pmt->SetSampleSize(pvi->bmiHeader.biSizeImage); DbgLog((LOG_TRACE, 1, "GetMediaType (iPosition = %d) <= %d x %d x %d", iPosition, pvi->bmiHeader.biWidth, pvi->bmiHeader.biHeight, pvi->bmiHeader.biBitCount)); return S_OK; }
HRESULT StaticSourceVideoPin::ApplyParametersToMT(CMediaType * pmt) { VIDEOINFOHEADER * pvi = (VIDEOINFOHEADER *)pmt->pbFormat; LONG width = this->m_pFilter->m_params->m_bitmapInfo.biWidth; LONG height = this->m_pFilter->m_params->m_bitmapInfo.biHeight; RECT rect = { 0, 0, width, height }; pvi->rcTarget = rect; pvi->rcSource = rect; pvi->bmiHeader.biWidth = width; pvi->bmiHeader.biHeight = height; pvi->bmiHeader.biClrImportant = 0; pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pvi->AvgTimePerFrame = this->m_pFilter->m_params->m_rtFrameLength; if (pmt->subtype == MEDIASUBTYPE_RGB32) { pvi->bmiHeader.biCompression = BI_RGB; pvi->bmiHeader.biBitCount = 32; pvi->bmiHeader.biPlanes = 1; pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader); } else if (pmt->subtype == MEDIASUBTYPE_RGB24) { pvi->bmiHeader.biCompression = BI_RGB; pvi->bmiHeader.biBitCount = 24; pvi->bmiHeader.biPlanes = 1; pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader); } else if (pmt->subtype == MEDIASUBTYPE_YUY2) { pvi->bmiHeader.biCompression = MAKEFOURCC('Y','U','Y','2'); pvi->bmiHeader.biBitCount = 16; pvi->bmiHeader.biPlanes = 1; pvi->bmiHeader.biSizeImage = 2 * ((width * height) >> 1) + (width * height); }
static int nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) { void *pixels = NULL; AndroidBitmap_lockPixels(_env, jbitmap, &pixels); jint id = 0; if (pixels != NULL) { id = (jint)dispatchTab.AllocationCubeCreateFromBitmap(con, (RsType)type, (RsAllocationMipmapControl)mip, pixels, GetBitmapSize(_env, jbitmap), usage); AndroidBitmap_unlockPixels(_env, jbitmap); } return id; }
static void nAllocationCopyToBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) { AndroidBitmapInfo info; memset(&info, 0, sizeof(info)); AndroidBitmap_getInfo(_env, jbitmap, &info); void *pixels = NULL; AndroidBitmap_lockPixels(_env, jbitmap, &pixels); if (pixels != NULL) { dispatchTab.AllocationCopyToBitmap(con, (RsAllocation)alloc, pixels, GetBitmapSize(_env, jbitmap)); AndroidBitmap_unlockPixels(_env, jbitmap); } //bitmap.notifyPixelsChanged(); }
///////////////////////////////////////////////////////////////////////////// // // This static function can be used to draw CBitmaps as well as ZDibs. // ///////////////////////////////////////////////////////////////////////////// zBOOL DrawBitmap( CDC& dc, CBitmap *pBitmap, const CRect *rectTgt, const CRect *rectSrc ) { // Compute rectangles where 0 specified. CRect rect; if ( rectSrc == 0 ) { // If no source rect, use whole bitmap. rect = CRect( CPoint( 0, 0 ), GetBitmapSize( pBitmap ) ); rectSrc = ▭ } if ( rectTgt == 0 ) { // If no destination rect, use source. rectTgt = rectSrc; } // Create memory DC. CDC memDC; memDC.CreateCompatibleDC( &dc ); CBitmap *pOldBmp = memDC.SelectObject( pBitmap ); // Blast bits from memory DC to target DC. Use StretchBlt if size // is different. zBOOL bRC = FALSE; if ( rectTgt->Size( ) == rectSrc->Size( ) ) { bRC = dc.BitBlt( rectTgt->left, rectTgt->top, rectTgt->Width( ), rectTgt->Height( ), &memDC, rectSrc->left, rectSrc->top, SRCCOPY ); } else { dc.SetStretchBltMode( COLORONCOLOR ); bRC = dc.StretchBlt( rectTgt->left, rectTgt->top, rectTgt->Width( ), rectTgt->Height( ), &memDC, rectSrc->left, rectSrc->top, rectSrc->Width( ), rectSrc->Height( ), SRCCOPY ); } memDC.SelectObject( pOldBmp ); return( bRC ); }
static void nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) { AndroidBitmapInfo info; memset(&info, 0, sizeof(info)); AndroidBitmap_getInfo(_env, jbitmap, &info); void *pixels = NULL; AndroidBitmap_lockPixels(_env, jbitmap, &pixels); if (pixels != NULL) { dispatchTab.Allocation2DData(con, (RsAllocation)alloc, 0, 0, 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X, info.width, info.height, pixels, GetBitmapSize(_env, jbitmap), 0); AndroidBitmap_unlockPixels(_env, jbitmap); } }
BOOL WINAPI ChangeBackground(HBITMAP& hNewBGBitmap, DWORD& dwOverlayBGColor) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); srand(time(NULL)+GetTickCount()); dwOverlayBGColor=COLORKEY; objSettings.dbBgImage.Destroy(); objSettings.szBitmapSize=GetBitmapSize(hNewBGBitmap); objSettings.dbBgImage.Create(objSettings.szBitmapSize.cx, objSettings.szBitmapSize.cy); CDC dcScreen,dcReal; dcScreen.CreateDC("DISPLAY", NULL, NULL, NULL); dcReal.CreateCompatibleDC(&dcScreen); HBITMAP hbmpTmp=(HBITMAP)CopyImage(hNewBGBitmap,IMAGE_BITMAP, objSettings.szBitmapSize.cx, objSettings.szBitmapSize.cy, 0); objSettings.dbBgImage.SetBitmap(&dcReal,hbmpTmp); DWORD dwErr=GetLastError(); ClearBitmap(hbmpTmp); InitImage(); return TRUE; };
/** * Create the clipboard data for a given format. * This assumes that the clipboard is open. * @param HGLOBAL hData the clipboard data. * @param size_t maxMemory the max memory we want to allow to prevent lock-up. * @return ClipboardData*|NULL either the data or NULL if the format does not exist. */ ClipboardData* ClipboardData::FromClipboardBitmap(HGLOBAL hData, size_t maxMemory) { // check the memory size. if (maxMemory > 0 && GetBitmapSize((HBITMAP)hData) > maxMemory) { return NULL; } // build the data clipboard so we can restore it. ClipboardData *cf = new ClipboardData(); // copy the meta file. cf->data = static_cast<void*>(CopyBitmap( (HBITMAP)hData )); cf->dataSize = 0; cf->uFormat = CF_BITMAP; // return the created filedata. return cf; }
bool DeviceNull::init_color_frame() { BITMAPINFO f_bmi = {0}; void * f_buffer = nullptr; // create a device independent bitmap of the correct format f_bmi.bmiHeader.biCompression = BI_RGB; f_bmi.bmiHeader.biBitCount = m_private->m_resolution.m_bits_per_pixel; f_bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); f_bmi.bmiHeader.biWidth = m_private->m_resolution.m_width; f_bmi.bmiHeader.biHeight = m_private->m_resolution.m_height; f_bmi.bmiHeader.biPlanes = 1; f_bmi.bmiHeader.biSizeImage = GetBitmapSize(&f_bmi.bmiHeader); f_bmi.bmiHeader.biClrImportant = 0; auto f_dib = CreateDIBSection(nullptr, &f_bmi, DIB_RGB_COLORS, &f_buffer, nullptr, 0); if (!f_dib) return false; // attach the DIB to a device context auto f_hdc = GetDC(nullptr); auto f_paintdc = CreateCompatibleDC(f_hdc); SetMapMode(f_paintdc, GetMapMode(f_hdc)); SelectObject(f_paintdc, f_dib); // text properties SetBkColor (f_paintdc, RGB (0,0,0)); SetTextColor(f_paintdc, RGB(255,255,255)); SetTextAlign(f_paintdc, TA_CENTER); // write the text to the DIB const wchar_t *f_msg = L"No Kinect available."; TextOut(f_paintdc, 160, 110, f_msg, wcslen(f_msg)); // save the buffer memcpy(m_private->m_color_data.data(), f_buffer, m_private->m_color_data.size()); // cleanup DeleteDC(f_paintdc); return true; }
HRESULT CPushPinBitmapSet::GetMediaType(CMediaType *pMediaType) { CAutoLock cAutoLock(m_pFilter->pStateLock()); CheckPointer(pMediaType, E_POINTER); // If the bitmap files were not loaded, just fail here. if (!m_bFilesLoaded) return E_FAIL; // Allocate enough room for the VIDEOINFOHEADER and the color tables VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER*)pMediaType->AllocFormatBuffer(SIZE_PREHEADER + m_cbBitmapInfo[m_iCurrentBitmap]); if (pvi == 0) return(E_OUTOFMEMORY); // Initialize the video info header ZeroMemory(pvi, pMediaType->cbFormat); pvi->AvgTimePerFrame = m_rtFrameLength; // Copy the header info from the current bitmap memcpy(&(pvi->bmiHeader), m_pBmi[m_iCurrentBitmap], m_cbBitmapInfo[m_iCurrentBitmap]); // Set image size for use in FillBuffer pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader); // Clear source and target rectangles SetRectEmpty(&(pvi->rcSource)); // we want the whole image area rendered SetRectEmpty(&(pvi->rcTarget)); // no particular destination rectangle pMediaType->SetType(&MEDIATYPE_Video); pMediaType->SetFormatType(&FORMAT_VideoInfo); pMediaType->SetTemporalCompression(FALSE); // Work out the GUID for the subtype from the header info. const GUID SubTypeGUID = GetBitmapSubtype(&pvi->bmiHeader); pMediaType->SetSubtype(&SubTypeGUID); pMediaType->SetSampleSize(pvi->bmiHeader.biSizeImage); return S_OK; }
// See Directshow help topic for IAMStreamConfig for details on this method HRESULT CVCamStream::GetMediaType(int iPosition, CMediaType *pmt) { if (iPosition < 0) return E_INVALIDARG; if (iPosition > 8) return VFW_S_NO_MORE_ITEMS; if (iPosition == 0) { *pmt = m_mt; return S_OK; } // TODO: the pvi is mostly duplicated from GetStreamCaps DECLARE_PTR(VIDEOINFOHEADER, pvi, pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER))); ZeroMemory(pvi, sizeof(VIDEOINFOHEADER)); pvi->bmiHeader.biCompression = BI_RGB; pvi->bmiHeader.biBitCount = 24; pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pvi->bmiHeader.biWidth = 80 * iPosition; pvi->bmiHeader.biHeight = 60 * iPosition; pvi->bmiHeader.biPlanes = 1; pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader); pvi->bmiHeader.biClrImportant = 0; pvi->AvgTimePerFrame = 1000000; SetRectEmpty(&(pvi->rcSource)); // we want the whole image area rendered. SetRectEmpty(&(pvi->rcTarget)); // no particular destination rectangle pmt->SetType(&MEDIATYPE_Video); pmt->SetFormatType(&FORMAT_VideoInfo); pmt->SetTemporalCompression(TRUE); // Work out the GUID for the subtype from the header info. /*const GUID SubTypeGUID = GetBitmapSubtype(&pvi->bmiHeader); pmt->SetSubtype(&SubTypeGUID);*/ pmt->SetSubtype(&MEDIASUBTYPE_H264); pmt->SetSampleSize(pvi->bmiHeader.biSizeImage); return NOERROR; } // GetMediaType
void CLOSTexture::RecomputeTexture(int unit) { // If the map was resized, delete and regenerate the texture if (m_Texture) { CmpPtr<ICmpTerrain> cmpTerrain(m_Simulation, SYSTEM_ENTITY); if (cmpTerrain && m_MapSize != (ssize_t)cmpTerrain->GetVerticesPerSide()) DeleteTexture(); } bool recreated = false; if (!m_Texture) { ConstructTexture(unit); recreated = true; } PROFILE("recompute LOS texture"); std::vector<u8> losData; losData.resize(GetBitmapSize(m_MapSize, m_MapSize)); CmpPtr<ICmpRangeManager> cmpRangeManager(m_Simulation, SYSTEM_ENTITY); if (!cmpRangeManager) return; ICmpRangeManager::CLosQuerier los(cmpRangeManager->GetLosQuerier(g_Game->GetPlayerID())); GenerateBitmap(los, &losData[0], m_MapSize, m_MapSize); if (CRenderer::IsInitialised() && g_Renderer.m_Options.m_SmoothLOS && recreated) { g_Renderer.BindTexture(unit, m_TextureSmooth1); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_MapSize + g_BlurSize - 1, m_MapSize + g_BlurSize - 1, GL_ALPHA, GL_UNSIGNED_BYTE, &losData[0]); g_Renderer.BindTexture(unit, m_TextureSmooth2); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_MapSize + g_BlurSize - 1, m_MapSize + g_BlurSize - 1, GL_ALPHA, GL_UNSIGNED_BYTE, &losData[0]); } g_Renderer.BindTexture(unit, m_Texture); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_MapSize + g_BlurSize - 1, m_MapSize + g_BlurSize - 1, GL_ALPHA, GL_UNSIGNED_BYTE, &losData[0]); }
void UpdateBitmapColors(HBITMAP hbmp, COLORREF textColor, COLORREF bgColor) { if ((textColor & 0xFFFFFF) == WIN_COL_BLACK && (bgColor & 0xFFFFFF) == WIN_COL_WHITE) return; // color order in DIB is blue-green-red-alpha int base[4] = { GetBValueSafe(textColor), GetGValueSafe(textColor), GetRValueSafe(textColor), 0 }; int diff[4] = { GetBValueSafe(bgColor) - base[0], GetGValueSafe(bgColor) - base[1], GetRValueSafe(bgColor) - base[2], 255 }; HDC hDC = GetDC(NULL); BITMAPINFO bmi = { 0 }; SizeI size = GetBitmapSize(hbmp); bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader); bmi.bmiHeader.biWidth = size.dx; bmi.bmiHeader.biHeight = size.dy; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biCompression = BI_RGB; int bmpBytes = size.dx * size.dy * 4; ScopedMem<unsigned char> bmpData((unsigned char *)malloc(bmpBytes)); CrashIf(!bmpData); if (GetDIBits(hDC, hbmp, 0, size.dy, bmpData, &bmi, DIB_RGB_COLORS)) { for (int i = 0; i < bmpBytes; i++) { int k = i % 4; bmpData[i] = (uint8_t)(base[k] + mul255(bmpData[i], diff[k])); } SetDIBits(hDC, hbmp, 0, size.dy, bmpData, &bmi, DIB_RGB_COLORS); } ReleaseDC(NULL, hDC); }
CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(FX_LPCWSTR filename) { CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); if (pPlatform->m_GdiplusExt.IsAvailable()) { WINDIB_Open_Args_ args; args.flags = WINDIB_OPEN_PATHNAME; args.path_name = filename; return pPlatform->m_GdiplusExt.LoadDIBitmap(args); } HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)filename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); if (hBitmap == NULL) { return NULL; } HDC hDC = CreateCompatibleDC(NULL); int width, height; GetBitmapSize(hBitmap, width, height); CFX_DIBitmap* pDIBitmap = FX_NEW CFX_DIBitmap; if (!pDIBitmap) { DeleteDC(hDC); return NULL; } if (!pDIBitmap->Create(width, height, FXDIB_Rgb)) { delete pDIBitmap; DeleteDC(hDC); return NULL; } CFX_ByteString info = GetBitmapInfo(pDIBitmap); int ret = GetDIBits(hDC, hBitmap, 0, height, pDIBitmap->GetBuffer(), (BITMAPINFO*)(FX_LPCSTR)info, DIB_RGB_COLORS); if (!ret) { if (pDIBitmap) { delete pDIBitmap; } pDIBitmap = NULL; } DeleteDC(hDC); return pDIBitmap; }
BOOL WIACamera::BitmapUtils::FillBitmapFileHeader(LPCVOID pDib, PBITMAPFILEHEADER pbmfh) { ULONG nSize = GetBitmapSize(pDib); if (nSize == 0) { return FALSE; } ULONG nOffset = GetBitmapOffsetBits(pDib); if (nOffset == 0) { return FALSE; } pbmfh->bfType = MAKEWORD('B', 'M'); pbmfh->bfSize = sizeof(BITMAPFILEHEADER) + nSize; pbmfh->bfReserved1 = 0; pbmfh->bfReserved2 = 0; pbmfh->bfOffBits = sizeof(BITMAPFILEHEADER) + nOffset; return TRUE; }
// // GetMediaType // // Prefer 5 formats - 8, 16 (*2), 24 or 32 bits per pixel // // Prefered types should be ordered by quality, with zero as highest quality. // Therefore, iPosition = // 0 Return a 24bit mediatype "as the default" since I guessed it might be faster though who knows // 1 Return a 24bit mediatype // 2 Return 16bit RGB565 // 3 Return a 16bit mediatype (rgb555) // 4 Return 8 bit palettised format // >4 Invalid // except that we changed the orderings a bit... // HRESULT CPushPinDesktop::GetMediaType(int iPosition, CMediaType *pmt) // AM_MEDIA_TYPE basically == CMediaType { CheckPointer(pmt, E_POINTER); CAutoLock cAutoLock(m_pFilter->pStateLock()); if(m_bFormatAlreadySet) { // you can only have one option, buddy, if setFormat already called. (see SetFormat's msdn) if(iPosition != 0) return E_INVALIDARG; VIDEOINFO *pvi = (VIDEOINFO *) m_mt.Format(); // Set() copies these in for us pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader); // calculates the size for us, after we gave it the width and everything else we already chucked into it // pmt->SetSampleSize(pvi->bmiHeader.biSizeImage); // nobody uses sample size anyway :P pmt->Set(m_mt); VIDEOINFOHEADER *pVih1 = (VIDEOINFOHEADER*) m_mt.pbFormat; VIDEOINFO *pviHere = (VIDEOINFO *) pmt->pbFormat; return S_OK; } // do we ever even get past here? hmm if(iPosition < 0) return E_INVALIDARG; // Have we run out of types? if(iPosition > 6) return VFW_S_NO_MORE_ITEMS; VIDEOINFO *pvi = (VIDEOINFO *) pmt->AllocFormatBuffer(sizeof(VIDEOINFO)); if(NULL == pvi) return(E_OUTOFMEMORY); // Initialize the VideoInfo structure before configuring its members ZeroMemory(pvi, sizeof(VIDEOINFO)); if(iPosition == 0) { // pass it our "preferred" which is 16 bits...I guess...haven't really researched it, but do want it to have a consistent default. iPosition = 3; // 32 -> 24 (2): getdibits took 2.251ms // 32 -> 32 (1): getdibits took 2.916ms // except those numbers might be misleading in terms of total speed...hmm... } switch(iPosition) { case 1: { // 32bit format // Since we use RGB888 (the default for 32 bit), there is // no reason to use BI_BITFIELDS to specify the RGB // masks [sometimes even if you don't have enough bits you don't need to anyway?] // Also, not everything supports BI_BITFIELDS ... pvi->bmiHeader.biCompression = BI_RGB; pvi->bmiHeader.biBitCount = 32; break; } case 2: { // Return our 24bit format, same as above comments pvi->bmiHeader.biCompression = BI_RGB; pvi->bmiHeader.biBitCount = 24; break; } case 3: { // 16 bit per pixel RGB565 BI_BITFIELDS // Place the RGB masks as the first 3 doublewords in the palette area for(int i = 0; i < 3; i++) pvi->TrueColorInfo.dwBitMasks[i] = bits565[i]; pvi->bmiHeader.biCompression = BI_BITFIELDS; pvi->bmiHeader.biCompression = BI_RGB; pvi->bmiHeader.biBitCount = 16; break; } case 4: { // 16 bits per pixel RGB555 // Place the RGB masks as the first 3 doublewords in the palette area for(int i = 0; i < 3; i++) pvi->TrueColorInfo.dwBitMasks[i] = bits555[i]; // LODO ??? need? not need? BI_BITFIELDS? Or is this the default so we don't need it? Or do we need a different type that doesn't specify BI_BITFIELDS? pvi->bmiHeader.biCompression = BI_BITFIELDS; pvi->bmiHeader.biBitCount = 16; break; } case 5: { // 8 bit palettised pvi->bmiHeader.biCompression = BI_RGB; pvi->bmiHeader.biBitCount = 8; pvi->bmiHeader.biClrUsed = iPALETTE_COLORS; break; } case 6: { // the i420 freak-o pvi->bmiHeader.biCompression = FOURCC_I420; // who knows if this is right LOL pvi->bmiHeader.biBitCount = 12; pvi->bmiHeader.biSizeImage = (getCaptureDesiredFinalWidth()*getCaptureDesiredFinalHeight()*3)/2; pmt->SetSubtype(&WMMEDIASUBTYPE_I420); break; } } // Now adjust some parameters that are the same for all formats pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pvi->bmiHeader.biWidth = getCaptureDesiredFinalWidth(); pvi->bmiHeader.biHeight = getCaptureDesiredFinalHeight(); pvi->bmiHeader.biPlanes = 1; if(pvi->bmiHeader.biSizeImage == 0) pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader); // calculates the size for us, after we gave it the width and everything else we already chucked into it pmt->SetSampleSize(pvi->bmiHeader.biSizeImage); // use the above size pvi->bmiHeader.biClrImportant = 0; pvi->AvgTimePerFrame = m_rtFrameLength; // from our config or default SetRectEmpty(&(pvi->rcSource)); // we want the whole image area rendered. SetRectEmpty(&(pvi->rcTarget)); // no particular destination rectangle pmt->SetType(&MEDIATYPE_Video); pmt->SetFormatType(&FORMAT_VideoInfo); pmt->SetTemporalCompression(FALSE); // Work out the GUID for the subtype from the header info. if(*pmt->Subtype() == GUID_NULL) { const GUID SubTypeGUID = GetBitmapSubtype(&pvi->bmiHeader); pmt->SetSubtype(&SubTypeGUID); } return NOERROR; } // GetMediaType
void CImageBkgTabCtrl::Draw(CCoolTabItem* pItem, CDC *pDC, UINT nStyle, BOOL bActive, BOOL bHovered, UINT nIndex) { CRect rect = pItem->m_rect; int status = BS_NORMAL; if(bActive) { status = BS_CLICKED; } else if(bHovered) { status = BS_HIGHLIGHT; } if(m_pImgTabBtn->m_pBitmaps[status][PS_LEFT] != NULL) { //Left PaintBmp(pDC, &rect, m_pImgTabBtn->m_pBitmaps[status][PS_LEFT], COPY); //Right if(m_pImgTabBtn->m_pBitmaps[status][PS_RIGHT] != NULL) { rect.left = rect.right - GetBitmapSize(m_pImgTabBtn->m_pBitmaps[status][PS_RIGHT]).cx; PaintBmp(pDC, &rect, m_pImgTabBtn->m_pBitmaps[status][PS_RIGHT], COPY); rect.right = rect.left; } //Mid rect.left = pItem->m_rect.left + GetBitmapSize(m_pImgTabBtn->m_pBitmaps[status][PS_LEFT]).cx; PaintBmp(pDC, &rect, m_pImgTabBtn->m_pBitmaps[status][PS_MID], STRETCH); rect = pItem->m_rect; } if(m_pImgTabBtn->m_pTabPart[TB_PT_SEPERATOR] != NULL && !bActive && nIndex > 0 && nIndex != (UINT)m_nActivePage + 1) { int height = GetBitmapSize(m_pImgTabBtn->m_pTabPart[TB_PT_SEPERATOR]).cy; if(rect.Height() > height) { rect.top += (rect.Height() - height) / 2; } PaintBmp(pDC, &rect, m_pImgTabBtn->m_pTabPart[TB_PT_SEPERATOR], COPY); rect = pItem->m_rect; } rect.top += 8; rect.left += 5; rect.right -= 2; //Icon if(pItem->m_hIcon != NULL && rect.Width() > 16) { ::DrawIconEx(pDC->m_hDC, rect.left, rect.top, pItem->m_hIcon, 16, 16, 0, NULL, DI_NORMAL); rect.left += 18; } //Text if (!pItem->m_sText.IsEmpty()) { rect.top += 2; CString sText = pItem->m_sText; BOOL bTruncated = FALSE; int len; for(len = sText.GetLength(); len > 4 && pDC->GetTextExtent(sText).cx > rect.Width(); len -= 2) { sText = sText.Left(len - 2); bTruncated = TRUE; } if(bTruncated) { if(len > 3) { sText = sText.Left(len - 3); } else { sText.Empty(); } sText += "..."; } pDC->DrawText(sText, &rect, DT_CENTER | DT_SINGLELINE); } }
// // GetMediaType // // Prefer 5 formats - 8, 16 (*2), 24 or 32 bits per pixel // // Prefered types should be ordered by quality, with zero as highest quality. // Therefore, iPosition = // 0 Return a 32bit mediatype // 1 Return a 24bit mediatype // 2 Return 16bit RGB565 // 3 Return a 16bit mediatype (rgb555) // 4 Return 8 bit palettised format // >4 Invalid // except that we changed the orderings a bit... // HRESULT CPushPinDesktop::GetMediaType(int iPosition, CMediaType *pmt) // AM_MEDIA_TYPE basically == CMediaType { CheckPointer(pmt, E_POINTER); CAutoLock cAutoLock(m_pFilter->pStateLock()); if(formatAlreadySet) { if(iPosition != 0) return E_INVALIDARG; // you only have one option, buddy. (see SetFormat's msdn) pmt->Set(m_mt); VIDEOINFOHEADER *pVih1 = (VIDEOINFOHEADER*)m_mt.pbFormat; // right ... VIDEOINFO *pviHere = (VIDEOINFO *) pmt->pbFormat; return S_OK; } if(iPosition < 0) return E_INVALIDARG; // Have we run off the end of types? if(iPosition > 5) return VFW_S_NO_MORE_ITEMS; VIDEOINFO *pvi = (VIDEOINFO *) pmt->AllocFormatBuffer(sizeof(VIDEOINFO)); if(NULL == pvi) return(E_OUTOFMEMORY); // Initialize the VideoInfo structure before configuring its members ZeroMemory(pvi, sizeof(VIDEOINFO)); if(iPosition == 0) { // pass it our "preferred" which is unchanged pixel format switch(m_iScreenBitRate) { case 24: iPosition = 2; break; case 16: iPosition = 2;//1;// 3; both fail in ffmpeg <sigh>. //2 -> 24 bit // iPosition = 1; // 32 bit possibly better... // 32 -> 24: getdibits took 2.251000ms // 32 -> 32: getdibits took 2.916480ms // except those numbers might be misleading... break; case 15: //iPosition = 4; //fear of crashing ffmpeg remains in my heart... iPosition = 2; break; case 8: iPosition = 5; break; case 32: iPosition = 2; // 32 -> 24 bit, figure since I'm already doing a conversion, might as well lose a few unused bits... break; default: // our high quality 32-bit, but we really should never get to the default option now... iPosition = 1; break; } } switch(iPosition) { case 1: { // Return our highest quality 32bit format // Since we use RGB888 (the default for 32 bit), there is // no reason to use BI_BITFIELDS to specify the RGB // masks. Also, not everything supports BI_BITFIELDS pvi->bmiHeader.biCompression = BI_RGB; pvi->bmiHeader.biBitCount = 32; break; } case 2: { // Return our 24bit format, same as above. pvi->bmiHeader.biCompression = BI_RGB; pvi->bmiHeader.biBitCount = 24; break; } case 3: { // 16 bit per pixel RGB565 BI_BITFIELDS // Place the RGB masks as the first 3 doublewords in the palette area for(int i = 0; i < 3; i++) pvi->TrueColorInfo.dwBitMasks[i] = bits565[i]; // LODO research this...does it come from the machine with...it set, or not? // pvi->bmiHeader.biCompression = BI_BITFIELDS; pvi->bmiHeader.biCompression = BI_RGB; pvi->bmiHeader.biBitCount = 16; break; } case 4: { // 16 bits per pixel RGB555 // Place the RGB masks as the first 3 doublewords in the palette area for(int i = 0; i < 3; i++) pvi->TrueColorInfo.dwBitMasks[i] = bits555[i]; // LODO // pvi->bmiHeader.biCompression = BI_BITFIELDS; pvi->bmiHeader.biBitCount = 16; break; } case 5: { // 8 bit palettised pvi->bmiHeader.biCompression = BI_RGB; pvi->bmiHeader.biBitCount = 8; pvi->bmiHeader.biClrUsed = iPALETTE_COLORS; break; } } // Adjust the parameters common to all formats pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pvi->bmiHeader.biWidth = m_iImageWidth; pvi->bmiHeader.biHeight = m_iImageHeight; pvi->bmiHeader.biPlanes = 1; pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader); pvi->bmiHeader.biClrImportant = 0; pvi->AvgTimePerFrame = m_rtFrameLength; // hard set currently... SetRectEmpty(&(pvi->rcSource)); // we want the whole image area rendered. SetRectEmpty(&(pvi->rcTarget)); // no particular destination rectangle pmt->SetType(&MEDIATYPE_Video); pmt->SetFormatType(&FORMAT_VideoInfo); pmt->SetTemporalCompression(FALSE); // Work out the GUID for the subtype from the header info. const GUID SubTypeGUID = GetBitmapSubtype(&pvi->bmiHeader); pmt->SetSubtype(&SubTypeGUID); pmt->SetSampleSize(pvi->bmiHeader.biSizeImage); return NOERROR; } // GetMediaType