DBL image_pattern(const Vector3d& EPoint, const BasicPattern* pPattern) { DBL xcoor = 0.0, ycoor = 0.0; int index = -1; RGBFTColour colour; const ImageData *image = dynamic_cast<const ImagePatternImpl*>(pPattern)->pImage; DBL Value; colour.Clear(); // going to have to change this // need to know if bump point is off of image for all 3 points if(map_pos(EPoint, pPattern, &xcoor, &ycoor)) return 0.0; else image_colour_at(image, xcoor, ycoor, colour, &index); // TODO ALPHA - we should decide whether we prefer premultiplied or non-premultiplied alpha if((index == -1) || image->Use) { if(image->Use == USE_ALPHA) { // use alpha channel or red channel if(image->data->HasTransparency() == true) Value = colour.transm(); else Value = colour.red(); // otherwise, just use the red channel } else // use grey-scaled version of the color Value = colour.Greyscale(); } else Value = index / 255.0; if(Value < 0) Value = 0; else if(Value > 1.0) Value = 1.0; return Value; }