tags:

views:

53

answers:

1

i m decreasing the resolution of a bitmap. i found a method on a site which is as follows

Average the values of all surrounding pixels, store that value in the choosen pixel location, then delete all the surrounding pixels.so a 4*6 matrix becomes a 4 x 3 matrix.

i am accessing pixels by this code

for(int y = 0; y < bmp.bmHeight; y++)   
  {      
      for(int x = 0; x < bmp.bmWidth; x++)     
      {         
          COLORREF rgb = dc.GetPixel(x, y);     
          BYTE r = GetRValue(rgb);       
          BYTE g = GetGValue(rgb);     
          BYTE b = GetBValue(rgb);            
          dc.SetPixel(x, y, RGB(r,g,b));      
      }   
  } 

tell me how can i delete a pixel?

+4  A: 

You can't really delete a pixel, a bitmap is a matrix of pixels. Rather, you should make a new bitmap of the intended size, and copy pixels into that.

GMan
oh i see. can u plz show me how to make a new bitmap of intended size and copy pixels into that?
Sweety Khan
That depends on what library you're using. So maybe you could tell that ;-)
Kleist
i m using MFC. this is a part of my code. CBitmap img; CDC dc; BITMAP bmp; img.LoadBitmapW(IDB_BIT); img.GetBitmap( CDC* pDC = this->GetDC(); dc.CreateCompatibleDC(pDC); CBitmap* pOld = dc.SelectObject(
Sweety Khan