kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Add a way to use an image as a source for a pipeline
rodzic
32c49e5ec1
commit
f2b1b4449e
|
@ -113,6 +113,19 @@ void ImagePipelineNodeArraySource::get_next_row_data(std::uint8_t* out_data)
|
|||
}
|
||||
|
||||
|
||||
ImagePipelineNodeImageSource::ImagePipelineNodeImageSource(const Image& source) :
|
||||
source_{source}
|
||||
{}
|
||||
|
||||
void ImagePipelineNodeImageSource::get_next_row_data(std::uint8_t* out_data)
|
||||
{
|
||||
if (next_row_ >= get_height()) {
|
||||
throw SaneException("Trying to access line that is out of bounds");
|
||||
}
|
||||
std::memcpy(out_data, source_.get_row_ptr(next_row_), get_row_bytes());
|
||||
next_row_++;
|
||||
}
|
||||
|
||||
void ImagePipelineNodeFormatConvert::get_next_row_data(std::uint8_t* out_data)
|
||||
{
|
||||
auto src_format = source_.get_format();
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#ifndef BACKEND_GENESYS_IMAGE_PIPELINE_H
|
||||
#define BACKEND_GENESYS_IMAGE_PIPELINE_H
|
||||
|
||||
#include "genesys_image.h"
|
||||
#include "genesys_image_pixel.h"
|
||||
#include "genesys_image_buffer.h"
|
||||
|
||||
|
@ -178,6 +179,23 @@ private:
|
|||
};
|
||||
|
||||
|
||||
/// A pipeline node that produces data from the given image
|
||||
class ImagePipelineNodeImageSource : public ImagePipelineNode
|
||||
{
|
||||
public:
|
||||
ImagePipelineNodeImageSource(const Image& source);
|
||||
|
||||
std::size_t get_width() const override { return source_.get_width(); }
|
||||
std::size_t get_height() const override { return source_.get_height(); }
|
||||
PixelFormat get_format() const override { return source_.get_format(); }
|
||||
|
||||
void get_next_row_data(std::uint8_t* out_data) override;
|
||||
|
||||
private:
|
||||
const Image& source_;
|
||||
std::size_t next_row_ = 0;
|
||||
};
|
||||
|
||||
// A pipeline node that converts between pixel formats
|
||||
class ImagePipelineNodeFormatConvert : public ImagePipelineNode
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue