-
Notifications
You must be signed in to change notification settings - Fork 45
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
Implement optional 8bpp dithering & image smooth scaling #282
Conversation
We can mask G & A in one go, saving an OR.
Probably already handled by the compiler, since this is unsigned.
Optimized for eInk
(Because we want to be able to only enable it on devices that can't do it in HW in our frontend).
Ripped out of the current Qt5 dev branch, and reduced to its essential components for testing in FBInk.
So we can implement a post-processing scaler pass
duplication... Let's see how much GCC will shout at me because I don't speak C++ xD.
I grok that better, plus, it'll come in handy with the next commit anyway
Don't play with pointers when you're tired -_-". We never actually had a buffer holding the *full* decoded image, only single lines. So of course trying to scale/print that assuming it was actually an image-sized buffer was at best printing random bits of heap, at worst segfaulting. Anyway, if a post-processing pass is needed, store each lines in a full buffer, and then use *that* as a source ;). Bonus point: I can revert the whole mess about the extra argument to OnEndDecode \o/
(Dither is initialized as true for Gray buffers).
So, let's leave it at that for now ;).
I'll be using lvimg.cpp's LVStretchImgSource to resize background images (to solve koreader/koreader#6345 (comment)). crengine/crengine/src/lvimg.cpp Line 1955 in 487d8c2
crengine/crengine/src/lvimg.cpp Line 2106 in 487d8c2
in lvrend.cpp's DrawBackgroundImage(), a bit like that: LVImageSourceRef img = enode->getParentNode()->getDocument()->getObjectImageSource(filepath);
int img_w =img->GetWidth();
int img_h =img->GetHeight();
[... some checks for CSS style width and height ...]
if ( new_w != img_w || new_h != img_h ) {
printf("bg image resized to w x h : %d %d\n", new_w, new_h);
img = LVCreateStretchFilledTransform(img, new_w, new_h, IMG_TRANSFORM_STRETCH, IMG_TRANSFORM_STRETCH, 0, 0);
img_w = new_w;
img_h = new_h;
} We would need it to stay a You implemented in this PR smooth scaling (and dithering) when drawing a LVImageSource to a |
@poire-z: Are the h/v transform fields a bitmask, or can there only be a single one set? |
Nope, not a bitmask. Just one of: crengine/crengine/include/lvimg.h Lines 92 to 98 in 487d8c2
but transform_h might be one and transform_v an other. (But it could be another function/class/method, like a new ResizeImage(). CoolReader only uses STRETCH for its own page background drawing.) |
@poire-z: Cool, might be doable then, just have to figure out which, if any, OnEndDecode is triggered ^^. (I suck at OOP ;p). (I'd probably only take this path is h && v == STRETCH, just in case, though). |
As discussed in koreader/koreader#1833 ;).
I expect the C++11 minor features (constexpr, nullptr) to fantastically blow up on the PB toolchain, so, this'll probably take a second PR with ifdeffery tweaks ;).