Untitled

mail@pastecode.io avatar
unknown
c_cpp
17 days ago
1.4 kB
3
Indexable
Never
#pragma once
#include <memory>
#include "render.h"

class DitherProcessor
{
public:
	void ReadImage(const char* input_file);
	void SaveCurrentImage(const char* output_file);
	void Process(int picture_mode, int brightness, int constrast, int gamma, int color);
	uint8_t* GetCurrentImage(size_t* length);

private:
	int width = 0;
	int height = 0;
	std::unique_ptr<uint8_t[]> source_image = nullptr;
	std::unique_ptr<uint8_t[]> current_image = nullptr;
};

#include "DitherProcessor.h"
#include "bmpView_JY.h"

void DitherProcessor::ReadImage(const char* input_file)
{
    uint8_t* src = 0;
	readBMP_JY(&src, &width, &height, input_file, BGR, true);
    source_image.reset(src);
    current_image = std::make_unique<uint8_t[]>(width * height * 3);
}

void DitherProcessor::SaveCurrentImage(const char* output_file)
{
	saveBMP_JY(current_image.get(), width, height, output_file, BGR, true);
}

void DitherProcessor::Process(int picture_mode, int brightness, int constrast, int gamma, int color)
{
    ePaperPictureSettings set;
    set.picture_mode = PMODE_CUSTOM;
    set.brightness = 0;
    set.contrast = 100;
    set.gamma = 0;
    set.color = 25;
    uint8_t* dst = process_dither_total(source_image.get(), width, height, set);
    current_image.reset(dst);
}

uint8_t* DitherProcessor::GetCurrentImage(size_t* length)
{
    *length = width * height * 3;
    return current_image.get();
}
Leave a Comment