-
Notifications
You must be signed in to change notification settings - Fork 309
Add shadow effect to libopenshot
#999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
a11c9b2
4551154
b020108
ed33b6d
6027f5d
ab80bd8
dae3766
11f8f78
2520c68
be5e2e9
9d2f082
f2f76e0
6da48a2
71d2be9
790f5a8
944bf0f
f0d415c
ee01994
61302db
95f6a68
c4e3c56
87d9d61
bb037c9
28b46d1
39962f9
461752f
b8238bb
a239b94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||
| * @file | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * @brief Source file for Frame class | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * @author Jonathan Thomas <jonathan@openshot.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * @author HaiVQ <me@haivq.com> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||
| * @ref License | ||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -113,6 +114,7 @@ Frame::~Frame() { | |||||||||||||||||||||||||||||||||||||||||||||||||
| audio.reset(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| #ifdef USE_OPENCV | ||||||||||||||||||||||||||||||||||||||||||||||||||
| imagecv.release(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| brga_image_cv.release(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -893,6 +895,13 @@ cv::Mat Frame::GetImageCV() | |||||||||||||||||||||||||||||||||||||||||||||||||
| return imagecv; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // Set pointer to OpenCV image object | ||||||||||||||||||||||||||||||||||||||||||||||||||
| void Frame::SetImageCV(cv::Mat _image) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| imagecv = _image; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| image = Mat2Qimage(_image); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| std::shared_ptr<QImage> Frame::Mat2Qimage(cv::Mat img){ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cv::cvtColor(img, img, cv::COLOR_BGR2RGB); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| QImage qimg((uchar*) img.data, img.cols, img.rows, img.step, QImage::Format_RGB888); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -906,11 +915,39 @@ std::shared_ptr<QImage> Frame::Mat2Qimage(cv::Mat img){ | |||||||||||||||||||||||||||||||||||||||||||||||||
| return imgIn; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // Set pointer to OpenCV image object | ||||||||||||||||||||||||||||||||||||||||||||||||||
| void Frame::SetImageCV(cv::Mat _image) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| imagecv = _image; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| image = Mat2Qimage(_image); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // Convert QImage to cv::Mat and vice versa | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // Frame class has GetImageCV, but it does not include alpha channel | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // so we need a separate methods which preserve alpha channel | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cv::Mat Frame::QImage2BGRACvMat(std::shared_ptr<QImage>& qimage) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cv::Mat cv_img( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| qimage->height(), qimage->width(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| CV_8UC4, (uchar*)qimage->constBits(), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| qimage->bytesPerLine() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return cv_img; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // Convert cv::Mat back to QImage | ||||||||||||||||||||||||||||||||||||||||||||||||||
| std::shared_ptr<QImage> Frame::BGRACvMat2QImage(cv::Mat img) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cv::Mat final_img; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cv::cvtColor(img, final_img, cv::COLOR_BGRA2RGBA); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| QImage qimage(final_img.data, final_img.cols, final_img.rows, final_img.step, QImage::Format_ARGB32); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| std::shared_ptr<QImage> imgIn = std::make_shared<QImage>(qimage.convertToFormat(QImage::Format_RGBA8888_Premultiplied)); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return imgIn; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| // Get BGRA | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cv::Mat Frame::GetBGRACvMat() { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!image) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // Fill with black | ||||||||||||||||||||||||||||||||||||||||||||||||||
| AddColor(width, height, color); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| brga_image_cv = QImage2BGRACvMat(image); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return brga_image_cv; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| void Frame::SetBGRACvMat(cv::Mat _image) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| brga_image_cv = _image; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+944
to
+949
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| brga_image_cv = QImage2BGRACvMat(image); | |
| return brga_image_cv; | |
| } | |
| void Frame::SetBGRACvMat(cv::Mat _image) { | |
| brga_image_cv = _image; | |
| bgra_image_cv = QImage2BGRACvMat(image); | |
| return bgra_image_cv; | |
| } | |
| void Frame::SetBGRACvMat(cv::Mat _image) { | |
| bgra_image_cv = _image; |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in variable name: should be 'bgra_image_cv' not 'brga_image_cv'. This should match the corrected variable declaration.
| brga_image_cv = QImage2BGRACvMat(image); | |
| return brga_image_cv; | |
| } | |
| void Frame::SetBGRACvMat(cv::Mat _image) { | |
| brga_image_cv = _image; | |
| bgra_image_cv = QImage2BGRACvMat(image); | |
| return bgra_image_cv; | |
| } | |
| void Frame::SetBGRACvMat(cv::Mat _image) { | |
| bgra_image_cv = _image; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||||||||||||||
| * @file | ||||||||||||||||||
| * @brief Header file for Frame class | ||||||||||||||||||
| * @author Jonathan Thomas <jonathan@openshot.org> | ||||||||||||||||||
| * @author HaiVQ <me@haivq.com> | ||||||||||||||||||
| * | ||||||||||||||||||
| * @ref License | ||||||||||||||||||
| */ | ||||||||||||||||||
|
|
@@ -106,6 +107,7 @@ namespace openshot | |||||||||||||||||
|
|
||||||||||||||||||
| #ifdef USE_OPENCV | ||||||||||||||||||
| cv::Mat imagecv; ///< OpenCV image. It will always be in BGR format | ||||||||||||||||||
| cv::Mat brga_image_cv; ///< OpenCV image. It will always be in BGR format | ||||||||||||||||||
|
||||||||||||||||||
| cv::Mat brga_image_cv; ///< OpenCV image. It will always be in BGR format | |
| cv::Mat brga_image_cv; ///< OpenCV image. It will always be in BGRA format (with alpha channel) |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in variable name: should be 'bgra_image_cv' not 'brga_image_cv'. The letters are transposed, which is inconsistent with the BGRA naming convention used throughout the codebase.
| cv::Mat brga_image_cv; ///< OpenCV image. It will always be in BGR format | |
| cv::Mat bgra_image_cv; ///< OpenCV image. It will always be in BGR format |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent naming convention: The method names 'QImage2BGRACvMat' and 'BGRACvMat2QImage' use '2' to mean "to", but the established naming pattern in the codebase is 'Mat2Qimage' which also uses '2'. However, these new methods inconsistently capitalize parts of the name (QImage vs Qimage, CvMat vs nothing). For consistency with the existing 'Mat2Qimage' method, consider naming these 'Qimage2BGRACvMat' and 'BGRACvMat2Qimage' or better yet, use more descriptive names like 'QImageToBGRACvMat' and 'BGRACvMatToQImage' which would be more readable.
| cv::Mat QImage2BGRACvMat(std::shared_ptr<QImage>& qimage); | |
| /// Convert OpenCV Mat to QImage (alpha channel included) | |
| std::shared_ptr<QImage> BGRACvMat2QImage(cv::Mat img); | |
| cv::Mat Qimage2BGRACvMat(std::shared_ptr<QImage>& qimage); | |
| /// Convert OpenCV Mat to QImage (alpha channel included) | |
| std::shared_ptr<QImage> BGRACvMat2Qimage(cv::Mat img); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in variable name: should be 'bgra_image_cv' not 'brga_image_cv'. This should match the corrected variable declaration.