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. problems with getting RGB values

problems with getting RGB values

Scheduled Pinned Locked Moved C / C++ / MFC
helpgraphicstutorial
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.
  • C Offline
    C Offline
    Cyberizen
    wrote on last edited by
    #1

    Hello i have been trying to get RGB values from a 24bit BITMAP following is the code : bitmap = (HBITMAP)LoadImage(NULL,path,IMAGE_BITMAP,0,0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); ::GetObject(bitmap,sizeof(bm),&bm); BYTE *pix = (BYTE*) bm.bmBits; //bm is of type BITMAP pixels pixel[216][331]; //file opened is 216 * 331 CClientDC dc(this); int k = 0; for(int j = 0; j <= height-1 ; j ++) { for(int i = 0; i <= width-1; i ++) { pixel[j][i].blue = pix[k++]; pixel[j][i].green = pix[k++]; pixel[j][i].red = pix[k++]; dc.SetPixel(i,j,RGB(pixel[j][i].red,pixel[j][i].green,pixel[j] [i].blue)); } } I am trying to figure out the problem i cant find it help me please the result that is displayed is not the correct image i mean its all inverted and rotated i dont understand the pixels values are there how to ARRANGE them please help me out

    L 1 Reply Last reply
    0
    • C Cyberizen

      Hello i have been trying to get RGB values from a 24bit BITMAP following is the code : bitmap = (HBITMAP)LoadImage(NULL,path,IMAGE_BITMAP,0,0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); ::GetObject(bitmap,sizeof(bm),&bm); BYTE *pix = (BYTE*) bm.bmBits; //bm is of type BITMAP pixels pixel[216][331]; //file opened is 216 * 331 CClientDC dc(this); int k = 0; for(int j = 0; j <= height-1 ; j ++) { for(int i = 0; i <= width-1; i ++) { pixel[j][i].blue = pix[k++]; pixel[j][i].green = pix[k++]; pixel[j][i].red = pix[k++]; dc.SetPixel(i,j,RGB(pixel[j][i].red,pixel[j][i].green,pixel[j] [i].blue)); } } I am trying to figure out the problem i cant find it help me please the result that is displayed is not the correct image i mean its all inverted and rotated i dont understand the pixels values are there how to ARRANGE them please help me out

      L Offline
      L Offline
      l a u r e n
      wrote on last edited by
      #2

      arent dc's inverted? try drawing from the bottom up :)


      "there is no spoon"
      biz stuff   about me

      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