1d access to a 2d type array

BlitzMax Forums/BlitzMax Programming/1d access to a 2d type array

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Ok, here's the idea: I have a type representing a pixel, e.g.
type pixel
  field r:float
  field g:float
  field b:float
  field i1:int
  field i2:int
end type


Then I'll create my 'image':
local myimage:pixel=new pixel[16,16]


(or something, maybe some more initializing, anyway, that's not the point here :P)

Anyway, I can access the pixel fields in a nested y,x FOR loop of course. But next to doing this I also want 1-dimensional access for both reading and writing. E.g. if I know the width and height (16 and 16) then I want to be able to run through the whole shebang in a for 256 loop. Oh.. and superstrict..!

How? :P I didn't find PTRs to be very cooperative, and going out of bounds (e.g. mypixel[255,0]) also wasn't much appreciated.