I am trying to convert from raw binary imageData as returned by the new 2.4
imageData prpoerty of images. For various reasons I don't want to use the
mouseColor function.

If anyone can help as binary data is a new area for me... This is what I am
guessing from the info in the reference stack:

    1) imagedata is encoded as binary data or a continuous string of "0's"
and "1's".

    2) This binary data is organised into chunks of 32 bits (ie 32 0's or
1's) to represent each pixel in the image.

    3) the first 8 bits are always 0 and can be discarded

    4) the next 8 bits determine the "red' value

    5) the next 8 bits determine the "green' value

    6) the next 8 bits determine the "blue' value

    7) To figure out which line the pixel should be on use the image width
and height properties to figure out what's going on.

So the following function returns the RGB values as a series of 0's and 1's:

function binaryToRGBPixel binaryPixel
  local always0, redBit, greenBit, blueBit
  get binaryDecode("b8b8b8b8", binaryPixel, always0, redBit, greenBit,
blueBit)
  put redBit, greenBit, blueBit into rgbTriplet
  return rgbTriplet
end binaryToRGBPixel

However this function does not seem to give the correct RGB values:

function binaryToRGBPixel binaryPixel
  local always0, redBit, greenBit, blueBit
  get binaryDecode("b8b8b8b8", binaryPixel, always0, redBit, greenBit,
blueBit)
  put 10 into baseNum
  put baseConvert(redBit, 2, baseNum) into redBit
  put baseConvert(greenBit, 2, baseNum) into greenBit
  put baseConvert(blueBit, 2, baseNum) into blueBit
  put redBit, greenBit, blueBit into rgbTriplet
  return rgbTriplet
end binaryToRGBPixel



Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to