![]() Int fileDescriptor = open(lpszFileName, O_CREAT | O_WRONLY) This is the SaveBitmapFile method that is used for saving the pixels: void BitmapUtility::SaveBitmapToFile(u8* pBitmapBits, long lWidth, long lHeight, unsigned short wBitsPerPixel, char* lpszFileName)īmpInfoHeader.biSize = sizeBITMAPINFOHEADER īmpInfoHeader.biBitCount = wBitsPerPixel īmpInfoHeader.biSizeImage = lWidth* lHeight * (wBitsPerPixel / 8) īfh.bfOffBits = sizeBITMAPINFOHEADER sizeBITMAPFILEHEADER īfh.bfSize = bfh.bfOffBits bmpInfoHeader.biSizeImage The code works well for resolutions such as 1024x768, 1280x1024, 1280x960, 1280x768 etc., but it completely scrambles the image for 1366x768. Uint8_t* pixels = (uint8_t*)CFDataGetBytePtr(dataRef) īitmapUtility::SaveBitmapToFile(pixels, width, height, 32, "/Users/Main/test32.bmp") I've implemented the following code in a C project on Mac OS X, for capturing the desktop screen: int ScreenCaptureRoutines::CaptureImage(int width, int height)ĬGImageRef img = CGWindowListCreateImage(captureRect, kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault) įprintf(stderr, "CGWindowListCreateImage failed\n!") ĬGDataProviderRef provider = CGImageGetDataProvider(img) ĬFDataRef dataRef = CGDataProviderCopyData(provider)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |