×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    73

    CFbsBitmap + DataAddress problem reading data from different pixel than 0 0

    Hello i want to get pixel colors from a CFsbBitmap by accessing pixel data (DataAddress() function)
    The problem is when i can get pixel data from point 0,0

    or point 25,0 but not from in ex 120,90 (which is the center of my image)
    bolded red text is responsible for getting pixel data.

    here is my code:



    Code:
    int y2x(int y)	{	return y * eCamWidth * 4;	}
    
    
    void CCameraEngine::ViewFinderFrameReady(CFbsBitmap& aFrame)
         {
    	
    	 CFbsBitmap * p;
    	 p = (&aFrame);
    	 TSize sajz;
    	 sajz = aFrame.SizeInPixels();
    	 eCamWidth 	= sajz.iWidth;
    	 eCamHeight = sajz.iHeight;
    	 
    int ai = y2x(90)+120*4;
    
    	 FrameFlush = true;
    
    int blen = eCamWidth * eCamHeight * 4;
    TUint32 * pdata = new TUint32[blen];
    	 p->LockHeap(false);	
    	 act_img->LockHeap(false);
    	 Mem::Copy(act_img->DataAddress(),p->DataAddress(),blen);
    	 Mem::Copy(pdata,p->DataAddress(),blen);
    	 p->UnlockHeap(false);	
    	 act_img->UnlockHeap(false);	
    //	 int ar = (TUint8)(pdata[0]);
    //	  int ag = (TUint8)(pdata[0] >> 8);
    //	  int ab = (TUint8)(pdata[0] >> 16);
    
    ab = (TUint8)(pdata[ai+0]);
    ag = (TUint8)(pdata[ai+1]);
    ar = (TUint8)(pdata[ai+2]);
    
    
    
    delete pdata;
    	
    	 
    	 FrameFlush = false;
    
    
         }

    As you can see i get the pixel index (in array) by calling y2x function and adding x factor to it its something like row * 4 * frame_width + column*4

    however i am unable to get color from the center of the image. (i always get 3 value for red green and blue no matter what)

  2. #2
    Registered User
    Join Date
    Jul 2013
    Posts
    3

    Re: CFbsBitmap + DataAddress problem reading data from different pixel than 0 0

    I'm no expert on the bitmap format, but what jumps out is that you calculate the bitmap size as (width * height * 4-bytes-per-pixel) i.e. the size in bytes, but then access it through 32-bit words (TUint32). Surely "pdata" should be declared as "TUint8"?

    (I guess the double copy is so that you can unlock the "p" memory more quickly? otherwise why not just read the pixels directly from it?)

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,568

    Re: CFbsBitmap + DataAddress problem reading data from different pixel than 0 0

    True.
    Code:
    TUint32 * pdata = new TUint32[blen];
    ...
    ab = (TUint8)(pdata[ai+0]);
    ag = (TUint8)(pdata[ai+1]);
    ar = (TUint8)(pdata[ai+2]);
    ab will contain a component of the first pixel, ag will contain the same component of the second pixel, ar will contain the same component of the third pixel. (I do not know which component is located on the lowest byte)
    The commented code is a bit closer, just ai (which could be used instead 0) is calculated with *4, if you remove that (and also from the y2x), the result may work.

  4. #4
    Registered User
    Join Date
    Jul 2013
    Posts
    73

    Re: CFbsBitmap + DataAddress problem reading data from different pixel than 0 0

    I changed TUint32 to TUint8 * pdata = new TUint8[blen]; it seems to work now (GetPixel() returns same values as pdata), however i am wondering how to memcopy then - the thing is the length of data. (


    int blen = eCamWidth * eCamHeight * 4;
    Mem::Copy(act_img->DataAddress(),p->DataAddress(),blen);
    eCamWidth * eCamHeight - gives 1/3 of image

    eCamWidth * eCamHeight * 3 gives almost whole image without 20 or less lines
    i am not quite sure of bitmap length then.

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,568

    Re: CFbsBitmap + DataAddress problem reading data from different pixel than 0 0

    Assuming 32-bit pixel mode (EColor16MU or EColor16MA), 32/8=4 is the correct multiplier.
    Assuming an unknown mode blen=CFbsBitmap::ScanLineLength(act_img->SizeInPixels().iWidth,act_img->DisplayMode())*act_img->SizeInPixels().iHeight
    Assuming that someone reads the documentation blen=act_img->DataSize() may also work

  6. #6
    Registered User
    Join Date
    Jul 2013
    Posts
    73

    Re: CFbsBitmap + DataAddress problem reading data from different pixel than 0 0

    I don't have such thing like DataSize(); finction. I even searched fbs.h for it (some funcs are private etc. (so i can make them public and access them)
    but i found only IMPORT_C TUint32* DataAddress() const; (ofcourse in class CFbsBitmap : public CBase)
    i tried
    blen=CFbsBitmap::ScanLineLength(act_img->SizeInPixels().iWidth,act_img->DisplayMode())*act_img->SizeInPixels().iHeight

    its the the same value ( eCamWidth * eCamHeight * 4 )


    i asked about this mem copy thus i thought i could have memory leaks
    Last edited by melepeta; 2013-10-30 at 13:49.

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,568

    Re: CFbsBitmap + DataAddress problem reading data from different pixel than 0 0

    I do not know, I was really just checking http://www.symlab.org/main/documenta...5-006DBE4046F6, it may be a newer method, missing from S60 3rd edition and the like.

Similar Threads

  1. How to use CFbsBitmap DataAddress() to do GrayScale
    By bulllogo in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2007-01-30, 12:11
  2. CFbsBitmap in SDK 3.0 Seems not allow using DataAddress()
    By kenwc in forum Symbian Media (Closed)
    Replies: 6
    Last Post: 2006-12-20, 10:53
  3. Replies: 3
    Last Post: 2005-08-16, 03:59
  4. CFbsBitmap pixel data
    By doctordwarf in forum Symbian
    Replies: 3
    Last Post: 2005-02-02, 18:12
  5. Replies: 6
    Last Post: 2004-04-01, 06:41

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •