thx klaus and Sandman...I think it is casting problem....
colors are from 16777215(white) to 0(black), so if I iterate over pixels I can get int of each pixel, like so
Dim color As Int = BM.GetPixel(x, y)
Dim res(4) As Int
res(0) = Bit.UnsignedShiftRight(Bit.And(color, 0xff000000), 24)
res(1) = Bit.UnsignedShiftRight(Bit.And(color, 0xff0000), 16)
res(2) = Bit.UnsignedShiftRight(Bit.And(color, 0xff00), 8)
res(3) = Bit.And(color, 0xff)
I think Erel wrote this, it should be equivalent to
int r = argb[i] >> 16 & 255;
int g = argb[i] >> 8 & 255;
int b = argb[i] & 255;
but
int color = r * 19 + g * 38 + b * 7 >> 6 & 255
give me cast type error, tried many things like
Dim color As Byte =Bit.ShiftRight(r * 19 + g * 38 + b * 7 , 6 ) And 255
but I need int here, not byte
Sandman, this code is part of old(new for me
) problem for printing image on BT printer. My printer(declared as ESC/POS?!) does not print images with libraries I found on B4x, so I have to roll my own. Can publish complete code if you think it will help. At the moment I can only print black box(filling that int() with 0), but I have to read it from locally stored image. So my code is OK, it can print, arrays and commands are OK, but image conversion is not.
thx again