void Hsv::rgb2hsv(osg::Vec4& hsv, const osg::Vec4& rgb) { // Let the Vec3 version do the work osg::Vec3 hsv3; osg::Vec3 rgb3(rgb[0], rgb[1], rgb[2]); rgb2hsv(hsv3,rgb3); // Copy to output (just pass alpha) hsv[HUE] = hsv3[HUE]; hsv[VALUE] = hsv3[VALUE]; hsv[SATURATION] = hsv3[SATURATION]; // Just pass alpha hsv[ALPHA] = rgb[ALPHA]; }
static inline int test_processor () { // create processor w/no video and no window zbar::Processor proc(debug, NULL); Handler handler; proc.set_handler(handler); if(debug) { proc.set_visible(); proc.user_wait(); } // generate barcode test image zbar::Image rgb3(0, 0, "RGB3"); // test cast to C image if(test_image_ean13(rgb3)) error("failed to generate image"); // test decode expect(zbar::ZBAR_EAN13, test_image_ean13_data); proc.process_image(rgb3); if(debug) proc.user_wait(); expect(zbar::ZBAR_EAN13, test_image_ean13_data); check_image(rgb3); if(rgb3.get_format() != zbar_fourcc('R','G','B','3')) error("image format mismatch"); expect(zbar::ZBAR_NONE, ""); proc.set_config(zbar::ZBAR_EAN13, zbar::ZBAR_CFG_ENABLE, false); proc.process_image(rgb3); check_image(rgb3); if(debug) proc.user_wait(); proc.set_config("ean13.en"); expect(zbar::ZBAR_EAN13, test_image_ean13_data); proc << rgb3; expect(zbar::ZBAR_EAN13, test_image_ean13_data); check_image(rgb3); if(debug) proc.user_wait(); { zbar::Image grey(rgb3.convert(zbar_fourcc('G','R','E','Y'))); expect(zbar::ZBAR_EAN13, test_image_ean13_data); proc << grey; zbar::Image y800 = grey.convert("Y800"); expect(zbar::ZBAR_EAN13, test_image_ean13_data); proc << y800; } if(debug) // check image data retention proc.user_wait(); expect(zbar::ZBAR_NONE, ""); return(0); }