-
Notifications
You must be signed in to change notification settings - Fork 511
Fix the issue that the imageScaleModes is not effective with editable image #2684
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
Changes from 4 commits
332adb5
16bd121
c5fd1ac
6b431d2
77a96a3
471ef87
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 |
|---|---|---|
|
|
@@ -22,12 +22,12 @@ | |
| #include "rendering/graphics/Recorder.h" | ||
|
|
||
| namespace pag { | ||
| ImageReplacement::ImageReplacement(ImageLayer* imageLayer, std::shared_ptr<PAGImage> pagImage) | ||
| ImageReplacement::ImageReplacement(int scaleMode, ImageBytes* bytes, | ||
| std::shared_ptr<PAGImage> pagImage) | ||
| : pagImage(std::move(pagImage)) { | ||
| auto imageFillRule = imageLayer->imageFillRule; | ||
| defaultScaleMode = imageFillRule ? imageFillRule->scaleMode : PAGScaleMode::LetterBox; | ||
| contentWidth = imageLayer->imageBytes->width; | ||
| contentHeight = imageLayer->imageBytes->height; | ||
| defaultScaleMode = scaleMode; | ||
|
||
| contentWidth = bytes->width; | ||
| contentHeight = bytes->height; | ||
| } | ||
|
|
||
| void ImageReplacement::measureBounds(tgfx::Rect* bounds) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,7 +202,8 @@ void PAGImageLayer::setImageInternal(std::shared_ptr<PAGImage> image) { | |
| } | ||
| delete replacement; | ||
| if (image != nullptr) { | ||
| replacement = new ImageReplacement(static_cast<ImageLayer*>(layer), image); | ||
| replacement = new ImageReplacement(getDefaultScaleMode(), | ||
| static_cast<ImageLayer*>(layer)->imageBytes, image); | ||
| } else { | ||
| replacement = nullptr; | ||
| } | ||
|
|
@@ -676,4 +677,18 @@ int64_t PAGImageLayer::contentDurationInternal() { | |
| return FrameToTime(maxFrame + 1, frameRate); | ||
| } | ||
|
|
||
| int PAGImageLayer::getDefaultScaleMode() { | ||
| int defaultScaleMode = PAGScaleMode::LetterBox; | ||
| int index = editableIndex(); | ||
| if (index >= 0 && file && file->imageScaleModes && !file->imageScaleModes->empty()) { | ||
| defaultScaleMode = file->imageScaleModes->at(index); | ||
| } | ||
| auto imageLayer = static_cast<ImageLayer*>(layer); | ||
| if (imageLayer && imageLayer->imageFillRule) { | ||
| defaultScaleMode = imageLayer->imageFillRule->scaleMode; | ||
| } | ||
|
|
||
| return defaultScaleMode; | ||
|
||
| } | ||
|
|
||
| } // namespace pag | ||
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.
ImageBytes* bytes 改成:ImageBytes* imageBytes, 避免含义误解。另外参数列表顺序调整一下,PAGImage调整到第一个。