How to resize an image ? 🤔
Adam D. Ruppe
destructionator at gmail.com
Fri Dec 25 23:08:37 UTC 2020
On Friday, 25 December 2020 at 22:59:55 UTC, vnr wrote:
> tmp.data = cast(ubyte[]) myImageData;
You set bytes here but an IndexedImage also needs a palette which
you didn't set up.
What format is your myImageData in? It might be more appropriate
to set it to a TrueColorImage.
IndexedImage: each pixel is one byte and it refers to a Color[]
palette.
TrueColorImage: each pixel is 4 bytes, red, green, blue, and
alpha inline.
If your image data isn't already read, you might load it as a
different thing instead with loadImageFromMemory. It all depends
what format you are starting with.
> writeln(guessImageFormatFromMemory(tci.imageData.bytes)); //
> "Unknown"
That function is also for reading files, not raw bytes like
inside the classes. The classes are supposed to already be in a
specific layout.
More information about the Digitalmars-d-learn
mailing list