In C, I can define a pointer to an array like this:
char b1[SOME_SIZE];
char (*b3)[3]=(char(*)[3])b1;
so that b3[i][j] == b1[i*3+j]
.
Can I declare such a pointer, b3
, in unsafe
C#?
My intention is to access bitmap channels as:
///...
unsafe {
//...
byte *target; //8bpp
byte (*source)[3]; //24bpp
//...
target[x]=(source[x][0]+source[x][1]+source[x][2])/3;
//...
I hope this way, using source[x][ch]
instead of source[x*3+ch]
to get some compiler optimization.