Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. faster method of bitmap reading

faster method of bitmap reading

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicsquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _tasleem
    wrote on last edited by
    #1

    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+

    R 1 Reply Last reply
    0
    • _ _tasleem

      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+

      R Offline
      R Offline
      Remco Hoogenboezem
      wrote on last edited by
      #2

      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); }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups