Is this how to calculate texture atlas coordinates

If I have a texture atlas, TexSize x TexSize square, and I want to access a Width x Height image at X,Y then are the texture coordinates

bottom left = X/TexSize, Y/TexSize
top right   = (X+Width)/TexSize, (Y+Height)/TexSize

The reason I ask is I have a 32x32 “texture atlas” with a 1x8 pixel vertical line starting at pixel 16,4. If I try and draw a rectangle filling it with the 1x8 line then some of it’s right and top row of pixels sample past the edge of the 1x8 line (i.e. the pixels from column 17 and the pixel from row 12 of the “atlas”).

The problem is only on a board with Mali 55, the same test works on my desktop, so I’m hoping it’s a driver issue, but
I’ve seen posts about adjusting for the texel center so I’ve started to doubt my coordinate calcluation.


To answer my own question. There is both a bug in the Mali driver and in my calculation. To sample the center of the texel 0.5 needs added to the X,Y (since 0,0 is the bottom left corner of the first texel, so 0.5/texWidth 0.5/texHeight is the center of the first texel).

Also, the width and height need adjusted by one i.e. the coordinates specify an infinitely thin line through the centre of the texels rather than a 1 rectangle as I was previously doing.