cacc::ByteImagecacc::HOST>::Ptr convert(mve::ByteImage::Ptr image) { if (image->channels() != 3 && image->channels() != 4) { throw std::runtime_error("Only support for 3/4 channels"); } int widht = image->width(); int height = image->height(); cacc::ByteImage<cacc::HOST>::Ptr ret; ret = cacc::ByteImage<cacc::HOST>::create(width, height); cacc::ByteImage<cacc::HOST>::Data & data = ret->data(); for (int y = 0; y < height; ++y) for (int x = 0; x < width; ++x) { uint pixel = 0x00000000; for (int c = 0; c < image->channels(); ++c) { pixel |= static_cast<uint>(image->at(x, y, c)) << 8 * c; } data.data_ptr[y * data.pitch + x] = pixel; } }
void print_number(mve::ByteImage::Ptr image, int x, int y, int digit, math::Vec3uc color) { assert(0 <= x && x < image->width() - 3); assert(0 <= y && y < image->height() - 5); assert(0 <= digit && digit <= 9); for(int i = 0; i < 3; ++i) { for(int j = 0; j < 5; ++j) { if(font[30 * j + digit * 3 + i]) { for(int c = 0; c < image->channels(); ++c) { image->at(x+i, y+j, c) = color[c]; } } } } }