×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    32

    Using TYPE_INT_8888_ARGB

    Hi can i use TYPE_INT_8888_ARGB
    for drawPixels using Nokia DirectGraphics and if yes
    how do i do that, coz when i used
    DirectGraphics.TYPE_USHORT_4444_ARGB i couldnt make a pixels fully opaque. i had specified a value like 0x7700 (this shud be red) but am not able to get the fully opage pixel.
    Plz could anyone help me with this, and could anyone provide me a link or a book to pixel manipulation techniques.

    Thanx

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    3
    try 0xFF00 for opaque red

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    32
    it give Illegal argument because the phone doesnt support it . so how do i get a red using TYPE_INT_4444ARGB

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    0xFF00 should be fully red using TYPE_USHORT_4444_ARGB, not TYPE_INT_8888_ARGB.
    I don't think you can use a format that is not the phone's native format (returned from getNativePixelFormat()).

    0xWXYZ

    W - alpha
    X - red
    Y - green
    Z - blue

    shmoove

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    32
    Cool got it , it worked,
    One more question, how do i get the Alpha, R , G , B component of a pixel
    in TYPE_USHORT_4444_ARGB format after i have read teh image thru getPixels()

  6. #6
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    With bitwise logical AND.
    Let's assume that pic[] is the array you got from getPixels. Then:
    Code:
    short alpha[i] = pic[i] & 0xf000;
    short red[i] = pic[i] & 0x0f00;
    short green[i] = pic[i] & 0x00f0;
    short blue[i] = pic[i] & 0x000f;
    shmoove

  7. #7
    Registered User
    Join Date
    Aug 2003
    Posts
    32
    is this the reverse ?

    short alpha[i] = pic[i] & 0xf000;
    short red[i] = pic[i] & 0x0f00;
    short green[i] = pic[i] & 0x00f0;
    short blue[i] = pic[i] & 0x000f;

    pic[i] = (alpha[i] <<12) | (red[i] << 8) | (green << 4) | (blue[i])

  8. #8
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    Well first of all I forgot to shift the results in my example, so sorry about that (looks like you figured it out though). For example:
    Code:
    short red[i] = pic[i] & 0x0f00 >> 8;
    short green[i] = pic[i] & 0x00f0 >> 4;
    And yes, the reverse is like you said.

    If you don't shift the values when extracting the components (like in my original example) then you don't need to shift them when recomposing the color:
    Code:
    pic[i] = alpha[i] | red[i] | green[i] | blue[i];

  9. #9
    Registered User
    Join Date
    Aug 2003
    Posts
    32
    Thanx it worked.
    Do u have any algorithms to play around with these pixel values,
    Like suppose i want to change all blue pixels in the image to red ? how do i do that etc,
    I also want to try rescaling etc. if u have any algos plz tell me .
    Thanx

  10. #10
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    Not really. I've been working on turn based games lately so I haven't had to deal with all that.

Posting Permissions

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