deokgyuhan / flutter_image_processing

MIT License
4 stars 3 forks source link

blending two images and add background Color and gradient to given image functionality #1

Open sadaqatdev opened 10 months ago

sadaqatdev commented 10 months ago

@deokgyuhan Thank you for the effort Can you please add the functionality to blending two images and also develop another method which add option to add gradient and colour to background of given image E.g the following is C++ example code

std::string composeImages(const std::string& base64Image1, const std::string& base64Image2) { // Decode Base64 strings to Mat objects efficiently cv::Mat mat1 = base64_decode_to_mat(base64Image1); cv::Mat mat2 = base64_decode_to_mat(base64Image2);

// Create a new Mat with appropriate dimensions cv::Mat combinedMat(cv::Size(std::max(mat1.cols, mat2.cols), mat1.rows + mat2.rows), CV_8UC3);

// Copy the image data efficiently mat1.copyTo(combinedMat(cv::Rect(0, 0, mat1.cols, mat1.rows))); mat2.copyTo(combinedMat(cv::Rect(0, mat1.rows, mat2.cols, mat2.rows)));

// Encode the combined Mat back to Base64 return mat_to_base64(combinedMat); }

// Helper functions for Base64 encoding/decoding using a third-party library cv::Mat base64_decode_to_mat(const std::string& base64Image) { std::vector decodedData = base64_decode(base64Image); cv::Mat mat = cv::imdecode(decodedData, cv::IMREAD_COLOR); return mat; }

std::string mat_to_base64(const cv::Mat& mat) { std::vector encodedData; cv::imencode(".png", mat, encodedData); return base64_encode(encodedData); }

Some help full links https://stackoverflow.com/questions/27296170/merge-two-mat-images-into-one

https://stackoverflow.com/questions/33239669/opencv-how-to-merge-two-images