Due to the user's requirements, the image needs to be acquired, the image that can be collected has a large part of the black border, the user needs to cut it, which is difficult to come.
I have found a lot of information, and there is no current thing available (Haha, China's programmer is this!), Including 9CBS website, cheeproject on Search, also Google, did not find a very suitable function or library ,
There are several examples on the Internet. About the image display, rotation, zoom, look, still did not understand, (mainly, it is not caused by the structure of the image), then take a VC digital image processing 〗, Mainly for the basic format and structure of the bitmap, after clearing, self-trial program to read the information inside the reading map, basically successful (reading the color image, does not involve the palette).
On this basis, I want to copy and save the source image, but this is a problem.
I have two days old, I still have to copy it (mainly for the pixel distribution of the bitmap), the copy is also a mess, and then I read a CDIB (this is also a jar A class named laiyiling, thank you!), There is a function about Rotate, let me suddenly
Here, I posted the outcome of these two days! ! !
// For 24-color bitmap, cropping // psrcfile source bitmap file // PDESTFILE target bitmap file // RECT To copy Rectangular area BOOL CGDIDLG :: CropbitMap (LPTSTSTSTSTSTSTSTSTFILE, LPRECT RECT)
{
CFILE FILE;
CfileException Fe;
BOOL RET = FALSE;
IF (! file.open) // Open source bitmap return ret; cfile f; cfileException E; if (! f.open (pdestfile, cfile :: modecreate | CFILE: :: MODECREATE | CFILE :: ModeWrite, & E) // The bitmap file Return False to copy;
DWord Retlen = 0; dword dwbitssize = file.getLength (); // file length
Hglobal HimageBuf = GLOBALLOC (GMEM_MOVEABLE | GMEM_ZEROINIT, DWBITSSIZE); if (! Himagebuf) {// Allocation Failback Returns file.close (); Return False;}
LPSTR lpImage = (LPSTR) GlobalLock (hImageBuf); // read into the image memory retLen = file.Read (lpImage, dwBitsSize); if (retLen // bitmap information analysis, int len = sizeof (BITMAPFILEHEADER); LPBITMAPFILEHEADER lpFhdr = (LPBITMAPFILEHEADER) lpImage; // file header information LPBITMAPINFOHEADER lpbmpInfo = (LPBITMAPINFOHEADER) (lpImage sizeof (BITMAPFILEHEADER)); // bitmap header int NLineBytes = 0, NHEight = 0, nwidth = 0; NHEIGHT = lpbmpinfo-> biheight; // Source image high nwidth = lpbmpinfo-> biwidth; // Source image wide int rectWidth = rect-> right-rect-> left; int rectHeight = rect-> bottom-rect-> top; // allocate an additional memory, storage size is rectWidth * rectHeight image pixel HGLOBAL hTmpBuf = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT RectWidth * RectHeight * 3); lpstr lppic = (lpstr) Globalock (HTMPBUF); // The integer bit of less than 4 per line is complement IF ((lpbmpinfo-> biwidth% 4! = 0) {nLineBytes = lpbmpinfo-> biwidth (lpbmpinfo-> biwidth)% 4;} else nlinebytes = lpbmpinfo-> biwidth; // Copy the original image to the newly allocated image storage area for (int y = 0; y // Transfer the pointer back to the start position LPPIC = LPPIC-RectWidth * RectHeight * 3; // Storage bitmap // In addition to the height, width, other information of the original image is not changed lpbmpinfo-> biWidth = RectWidth; lpbmpinfo-> biheight = RectHeight; F.Write (lpfhdr, len); // write file headfrite F.Write (LPBMPINFO, SIZEOF (BitMapInfoHeader); // Write diagram information F.Write (LPPIC, RectWidth * RectHeight * 3); // Write copied Image pixel f.close (); globalunlock (htmpbuf); // Release GlobalFree (HTMPBUF); GlobalUnlock (HimageBuf); // Release GlobalFree (HimageBuf); file.close (); return true;} The above function is still very imperfect, please praise more advice! ! ! ! However, I think it is very helpful for beginners for VC processing images, so I posted this contest. ! ! The main reference materials and websites are as follows: 1, www.9cbs.net (Image Processing and Algorithm Edition) 2, www.codeproject.com 3, www.vckbase.com 4, 〖VC Digital Image Processing〗 Second Edition I contact : LargeAndsmall@163.com, welcome more advice! ! !