piense
Posts: 6
Joined: Thu Jun 09, 2016 4:11 am

OpenVG & vgWritePixels

Wed Sep 13, 2017 11:15 pm

I'm trying to use OpenVG on a Pi3 to display some images. I get the image in a buffer in RAM and am using vgWritePixels to push that data to a window that's rendered to the screen. I'm using the hello_font example in raspberrypi/firmware as a starting point which defaults to using the VG_sARGB_8888 image format. That seems to work ok, but when I changed the image format to VG_sRGBA_8888 to better fit the format I have coming in, bad things happen. It's hard to describe but best as I can figure the image is a somewhat transparent version of the Red channel but certain rectangular areas of the image look normal. All I'm changing is the image format to the vgWritePixels call, and the corresponding mapping of the input channels in the source array. It's all very strange. Need be I can supply all the details and code but maybe those symptoms ring a bell for someone and can point me in the right direction to understanding what might be going on.

User avatar
Paeryn
Posts: 1574
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: OpenVG & vgWritePixels

Thu Sep 14, 2017 2:02 am

How are you mapping the channels? Assuming the data is an array of uint8_t then the first pixel is :-

for VG_sARGB, data[0] = blue, data[1] = green, data[2] = red, data[3] = alpha
for VG_sRGBA, data[0] = alpha, data[1] = blue, data[2] = green, data[3] = red

OpenVG defines the order as highest bits on the left when read as a word but the RPi is little-endian so the lowest byte is stored at the lowest address in memory (a 32-bit value of 0x01020304 is stored as 0x04, 0x03, 0x02, 0x01).
She who travels light — forgot something.

piense
Posts: 6
Joined: Thu Jun 09, 2016 4:11 am

Re: OpenVG & vgWritePixels

Fri Sep 15, 2017 5:14 am

I figured that much out, admittedly more by trial and error than an intelligent understanding of the problem. But the problem I'm seeing isn't a simple channel mapping problem. I rendered the primary colors to the screen and there's just blocks of picture missing in certain channels.

User avatar
Paeryn
Posts: 1574
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: OpenVG & vgWritePixels

Fri Sep 15, 2017 8:56 am

There shouldn't be bits missing in just some channels, the only thing which affects whether pixels are copied or not is scissoring. Any pixels that are updated get the values you pass in (unless you use the _pre formats which clamp a pixel's colour channels to its alpha value).

Can you give a short example of what you are doing?
She who travels light — forgot something.

Return to “Graphics programming”

Who is online

Users browsing this forum: No registered users and 2 guests