×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    47

    Converting EColor16M to EColor16MU ( pixel by pixel )

    Hi

    I have one very specific requirement where i need to convert one image into other image format.

    Source image is in EColor16M displaymode, while destination image needs to be in EColor16MU format.
    Source image also has a mask of EGray256 display mode.

    I am finding it difficulty in converting these as source is 24 bit while destination needs to be in 32 bit format.
    Moreover i cannot think of any logic of how to retain mask other information like alpha mode.

    Any logic will really help..

    Regards,
    Vniles

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    India
    Posts
    1,174

    Re: Converting EColor16M to EColor16MU ( pixel by pixel )

    Following code works for me:

    Code:
    CFbsBitmap* Convert16MUto16ML(CFbsBitmap &aBitmap)
    {
    TSize size = aBitmap.SizeInPixels();
    TDisplayMode dMode = aBitmap.DisplayMode();
    TBuf<512> buf;
    
    // if(iFileLogger)
    // {
    // _LIT(KFmt1, "New Camera Image received in game, w=%d, h=%d, cm=%d");
    // buf.Format(KFmt1, size.iWidth, size.iHeight, dMode);
    // iFileLogger->WriteLineL(buf);
    // }
    
    if (dMode != EColor16MU)
    return NULL;
    
    if (bitmap == NULL)
    {
    bitmap = new (ELeave) CFbsBitmap();
    bitmap->Create(size, EColor16M);
    }
    
    TInt sW = size.iWidth; //source width
    TInt sH = size.iHeight; //source height
    TInt dW = sW; //dest width
    TInt dH = sH; //dest Height
    TInt bpps = 4; //bytes per pixel on source
    TInt bppd = 3; //bytes per pixel on dest
    TInt l, c;
    TUint8 *src = (TUint8*) aBitmap.DataAddress(); //We have 0x00BBGGRR in each 4 bytes of this data (EColor16MU)
    TUint8 *dst = (TUint8*) bitmap->DataAddress(); //We want 0xRRGGBB here  (EColor16M)
    
    //copy the image pixel by piexel
    l = 0;
    while (l < sH && l < dH)
    {
    for (c = 0; c < sW; c++)
    {
    //in case the image is larger than the texture we stop at the last pixel that fits
    if (c >= dW)
    break;
    
    //dst[l*dW*bppd + c*bppd] = src[l*sW*bpps + c*bpps + 2]; //B
    //dst[l*dW*bppd + c*bppd + 1] = src[l*sW*bpps + c*bpps + 1]; //G
    //dst[l*dW*bppd + c*bppd + 2] = src[l*sW*bpps + c*bpps]; //R
    dst[l * dW * bppd + c * bppd] = src[l * sW * bpps + c * bpps]; //B
    dst[l * dW * bppd + c * bppd + 1] = src[l * sW * bpps + c * bpps
    + 1]; //G
    dst[l * dW * bppd + c * bppd + 2] = src[l * sW * bpps + c * bpps
    + 2]; //R
    }
    l++;
    }
    
    return bitmap;
    }

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    47

    Re: Converting EColor16M to EColor16MU ( pixel by pixel )

    Hi not_dying

    Thanks very much for logic of converting bitmap..

    Just got confused with function name. I wish to convert from EColor16M to EColor16MU.
    I guess i will need to modify some part of the function.

    while (l < sH && l < dH)
    {
    for (c = 0; c < sW; c++)
    {
    //in case the image is larger than the texture we stop at the last pixel that fits
    if (c >= dW)
    break;

    //dst[l*dW*bppd + c*bppd] = src[l*sW*bpps + c*bpps + 2]; //B
    //dst[l*dW*bppd + c*bppd + 1] = src[l*sW*bpps + c*bpps + 1]; //G
    //dst[l*dW*bppd + c*bppd + 2] = src[l*sW*bpps + c*bpps]; //R
    dst[l * dW * bppd + c * bppd] = src[l * sW * bpps + c * bpps]; //B
    dst[l * dW * bppd + c * bppd + 1] = src[l * sW * bpps + c * bpps
    + 1]; //G
    dst[l * dW * bppd + c * bppd + 2] = src[l * sW * bpps + c * bpps
    + 2]; //R
    }
    l++;
    }

    I think i will need to change above bit assignment . Will you please help me on how this will change?


    Thanks & Regards
    Niilesh

Similar Threads

  1. Converting bitmap from EColor64K to EColor16MU
    By marcinos in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2010-03-21, 09:49
  2. Replies: 4
    Last Post: 2010-03-04, 11:25
  3. Replies: 2
    Last Post: 2007-06-11, 14:39
  4. Is pixel by pixel painting possible in standard MIDP?
    By MobileVisuals in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2006-01-02, 19:37
  5. Get Pixel
    By softengilker in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2005-01-25, 10:51

Posting Permissions

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