Comments (9)
That would be handy indeed. I am also not sure how to make it elegant. The pointer parameter is indeed a way to have it optionally returned.
Another option is a record or object in return of GetThumbnail functions with Bitmap and FileInfo
from bgrabitmap.
And another option for AOptions is public variable in BGRAThumbnail unit, so there will be no need to initialize it and pass it, like those CheckersColor variables. So it will be initialized on initialization with default parameters.
from bgrabitmap.
Good idea.
There are indeed lots of parameters already and using an enum could help.
from bgrabitmap.
Would you like the thumbnail image to be smaller or keep it the same size and pad with empty pixels?
from bgrabitmap.
Something like that?
type
TBGRAThumbnailOptions = record
BackColor: TBGRAPixel; //default background
Checkers: boolean; //draw checkers to represent the transparent background of the image
Enlarge: boolean; //enlarge source image if smaller than the expected thumbnail size
Pad: boolean; //pad the thumbnail with BackColor to make it the expected size
end;
from bgrabitmap.
Not sure what Pad means. Width and Height could be there as well.
Here is early implementation. I moved I moved dimension check to InternalGetBitmapThumbnail, as GetStremThumbnail wouldn't work for all files. All AOptions functions are overload functions located below of original for compatibility with older code.
QuickInfo is not quite implemented. Still thinking around it. May be other way or other record type. Just to optionally return original resolution as well, so can be used alongside thumbnail if needed without additional access to picture file. Will think on this tomorrow.
from bgrabitmap.
About Pad, for now it would be set to True. When you ask for a thumbnail of size 128x128, then if the image is 128x64, then there will be unused pixels in the square 128x128 and they will be set to the BackColor. In other word the content is padded with this color.
But as you ask for images not to be enlarged, then you might for example just want to reduce the resolution, but not pad it with pixels. If the source image is 256x128, it would become 128x64 and not 128x128.
I moved I moved dimension check to InternalGetBitmapThumbnail, as GetStremThumbnail wouldn't work for all files.
I am not sure I understand
All AOptions functions are overload functions located below of original for compatibility with older code.
I agree that overload is a way to preserve compatibility. The functions that contains the actual code will be those that have the AOptions parameter, while the others functions will call the former. So that code is not duplicated and that all options are handled.
QuickInfo is not quite implemented. Still thinking around it. May be other way or other record type. Just to optionally return original resolution as well, so can be used alongside thumbnail if needed without additional access to picture file. Will think on this tomorrow.
That would be handy indeed. I am also not sure how to make it elegant. The pointer parameter is indeed a way to have it optionally returned.
from bgrabitmap.
I am not sure I understand
if AOptions.Enlarge = False section is in InternalGetBitmapThumbnail, rather than GetStreamThumbnail, as I was suggesting above, as not not every AReader is TBGRAImageReader
from bgrabitmap.
if AOptions.Enlarge = False section is in InternalGetBitmapThumbnail, rather than GetStreamThumbnail, as I was suggesting above, as not not every AReader is TBGRAImageReader
Not sure I see why. Enlarging can be done on any format.
from bgrabitmap.
Related Issues (20)
- BGRABitmap and FPC 3.2-fixes HOT 5
- compile error on bgrapixel.inc HOT 5
- Maintain the "bit format" of a file between reading and subsequent writing HOT 5
- Error: Duplicate identifier "FResolutionUnit" HOT 4
- Cannot compile package BGRABitmapPack 11.5.8 HOT 4
- Avoid WideString, use UnicodeString HOT 3
- libwebp.pas fails to compile if -Mobjfpc was not used at compilation. HOT 1
- Draw image center/cover no-repeat HOT 3
- Compile error with new visibility check on FPC trunk. HOT 1
- Function 'round' causing problems HOT 17
- libavif.pas fails to compile (mode Delphi) HOT 4
- crash on loading WEBP image on Windows-10 x64 (32bit EXE) when no DLL file is present (it must show nice msg about missing DLL) HOT 12
- -dBGRABITMAP_CORE and Canvas2D HOT 2
- Gradient text and last version 11.6. HOT 3
- Inconsistent kerning of TextSize HOT 1
- Can't close a Form after using draw() onto a TImage.Canvas HOT 3
- Support Inkscape Filters HOT 7
- Add line spacing setting
- Lazarus 3.2 and fpc 3.2.2 HOT 2
- BGRABitmapPack pulls too many libraries HOT 23
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bgrabitmap.