Results 1 to 3 of 3

Thread: alpha value when drawing image

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    1

    alpha value when drawing image

    Hello,

    I work on a freescale IMX51 target under WinCE.
    I am not able to activate alpha blending when drawing images.
    Can you help?

    Here is my EGL config:

    static const EGLint s_configAttribs[] =
    {
    EGL_RED_SIZE, 8,
    EGL_GREEN_SIZE, 8,
    EGL_BLUE_SIZE, 8,
    EGL_ALPHA_SIZE, 8,
    EGL_LUMINANCE_SIZE, EGL_DONT_CARE,
    EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
    EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
    EGL_NONE
    };

    Here is my image creation:

    VGuint *buffer = new VGuint [255*255];
    width = 255;
    height = 255;
    long i = 0;
    long size = width * height;

    VGuint *pter = buffer;
    for(unsigned int i=0; i<height; i++)
    {
    for(unsigned int j=0; j<width; j++)
    {
    *pter++ = RGBA(255,0,0,i);
    }

    }

    vgImage = vgCreateImage(VG_sRGBA_8888, width, height, VG_IMAGE_QUALITY_BETTER);
    vgImageSubData(vgImage, buffer, 4*width, VG_sRGBA_8888, 0, 0, width, height);

    VGErrorCode err = vgGetError ();

    free ( buffer );


    Here is the image rendering:

    float clearColor[4] = {0,0,0,0};
    vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
    vgClear(0, 0, i32WindowWidth, i32WindowHeight);

    vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
    vgLoadIdentity();

    vgDrawImage (vgImage);
    VGErrorCode err = vgGetError ();


    I can see a red square without any alpha shading or gradation.
    I checked that the image is OK in memory (alpha changes).
    I have the same behavior with a png image (image OK but no alpha change).
    Do I have to enable blending with a specific command (change VG_IMAGE_MODE? VG_COLOR_TRANSFORM?)

    Thank you for your support !

  2. #2

    Re: alpha value when drawing image

    When I render images I use:
    vgSeti( VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL );
    If I need to add a global alpha blend then I set:
    // set the global alpha in the color
    vgSetParameterfv(mgr->paint, VG_PAINT_COLOR, 4, col);
    vgSeti( VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY );

    This works for png files with per pixel alpha. As a side note I get much better performance when using a pre-multiplied image format.

    Brian
    Brian Edmond
    Crank Software Inc.
    Online: www.cranksoftware.com

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    1

    Re: alpha value when drawing image

    Quote Originally Posted by brian.edmond
    When I render images I use:
    vgSeti( VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL );
    If I need to add a global alpha blend then I set:
    // set the global alpha in the color
    vgSetParameterfv(mgr->paint, VG_PAINT_COLOR, 4, col);
    vgSeti( VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY );

    This works for png files with per pixel alpha. As a side note I get much better performance when using a pre-multiplied image format.

    Brian
    This works for me. Thanks.

Similar Threads

  1. Drawing masked sprites (textured quad with alpha channel)
    By lucafr in forum OpenGL ES general technical discussions
    Replies: 0
    Last Post: 02-07-2012, 09:39 AM
  2. Pattern drawing like image multiply draw mode
    By yuneng in forum OpenVG and VGU
    Replies: 5
    Last Post: 01-25-2008, 12:50 PM

Posting Permissions

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