windows - C++ Saving a Bitmap File -


So what am I trying to do that my program takes a screenshot and saves it on the computer? In fact, part of taking screenshots, I will run the program later, and first of all, I am trying to solve the problem of how to save the BMP file on the computer. I have received the following code that can help with that:

  // szPathName: Specifies the path name / lpBits: Specifies the bitmap bit / / w: image width / h Specifies: Image height ball saving image specifies (four * szPathName, zero * lpBits, int w, int h) {// FILE * pFile = fopen (szPathName, "wb") to create a new file; If (pFile == NULL) {return false; } Bitmapfoamer BMIH; BMIH.biSize = sizeof (BITMAPINFOHEADER); BMIH.biSizeImage = w * h * 3; // Create bitmaps for this OpenGL theme BMIH.biSize = sizeof (BITMAPINFOHEADER); BMIH.biWidth = w; BMIH.biHeight = H; BMIH.biPlanes = 1; BMIH.biBitCount = 24; BMIH.biCompression = BI_RGB; BMIH.biSizeImage = w * h * 3; Bitmapfiler BMFH; Int nBitsOffset = sizeof (BITMAPFILEHEADER) + BMIH. BECs; Long IIMAge = BMIH. BIICIJ; Long lFileSize = nBitsOffset + lImageSize; Bmfh.bfType = 'B' + ('M' <  

So what's the problem .... okay i did not understand varialbe ipbits There is a brief description of LPBits in code comments (LPBit: specifies bitmap bits) ... but I do not know exactly what it means. I tried to go to MSDN and after seeing the fopen and fclose function, phiklos is a function which will eventually use LPBits which I pass the sewimage function .... And well it appears that The fclose function differs on the basis of the lpBits variable, what was passed in the variable Fopen function, I tried to figure out what the "wb" of the FOPN function is but failed (MSDN). Search)

Question: In this case I "wb" to have uses as a second variable Fopian function in my previous address, what will Elpibit the Fokojh function? When I ask what will happen in reality, I mean ... what kind of variable is this (it is placed in the form of zero in the code * which basically allows any variable) and I Whatever feedback you can give.

refers to an array of bytes with the LPBit size size .

Each byte of the array will have a sequential component, in this order: B, G and R: Each pixel takes three bytes, one for each color component.

Please note that the code you post does not take into account the 4-byte alignment of the line of each image line should be aligned to the 4-byte limit for each image, so the correct for lImageSize The formula is:

  lImageSize = h * ((w * 3 + 3) & amp; 0xfffffffc);   

You can create lpbits by yourself:

  lpbits = new BYTE [lImageSize]; Using   

or createDIBSection () , the answer from Logicrat has been stated in

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -