faster method of bitmap reading
-
hi all i want to image processing.i want to load image to the picturebox and then extract the values from it. i m loading image on the picturebox through the code loadimage and variable of picbox.setbitmap. After loading this image i want to perfrom data extraction i mean read RGB values.what is fastest method of it either use the device context and and perform the data extraction or use the cimage atl class for this purpose. ddd+
-
hi all i want to image processing.i want to load image to the picturebox and then extract the values from it. i m loading image on the picturebox through the code loadimage and variable of picbox.setbitmap. After loading this image i want to perfrom data extraction i mean read RGB values.what is fastest method of it either use the device context and and perform the data extraction or use the cimage atl class for this purpose. ddd+
Hmm the fastest way to load files into memory that I know if is by using memory mapped files. Map the entire file into your process address space. I assume that you are using a bitmap file format?? You could do something like this: HANDLE hFile; HANDLE hFileMappingObject; BYTE * lpBaseAddress; BITMAPFILEHEADER * lpBitmapFileHeader; BITMAPINFOHEADER * lpBitmapInfoHeader; RGBQUAD * lpRGBQuad; BYTE * lpColorIndexArray; if(OpenDialog1->Execute()) { hFile=CreateFile(OpenDialog1->FileName.c_str(),GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); if(hFile==INVALID_HANDLE_VALUE) { MessageBox(Handle,"Could not open file","Error",MB_OK|MB_ICONERROR); return; } hFileMappingObject=CreateFileMapping(hFile,NULL,PAGE_READWRITE|SEC_COMMIT,0,0,NULL); if(hFileMappingObject==NULL) { MessageBox(Handle,"Could not create file mapping object","Error",MB_OK|MB_ICONERROR); CloseHandle(hFile); return; } lpBaseAddress=(BYTE*)MapViewOfFile(hFileMappingObject,FILE_MAP_WRITE,0,0,0); if(lpBaseAddress==NULL) { MessageBox(Handle,"Could not map view of file","Error",MB_OK|MB_ICONERROR); CloseHandle(hFileMappingObject); CloseHandle(hFile); return; } lpBitmapFileHeader=(BITMAPFILEHEADER*)&lpBaseAddress[0]; lpBitmapInfoHeader=(BITMAPINFOHEADER*)&lpBaseAddress[sizeof(BITMAPFILEHEADER)]; lpRGBQuad=(RGBQUAD*)&lpBaseAddress[sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)]; lpColorIndexArray=&lpBaseAddress[lpBitmapFileHeader->bfOffBits]; //Use lpColorIndexArray to acces your RGB values UnmapViewOfFile(lpBaseAddress); CloseHandle(hFileMappingObject); CloseHandle(hFile); }