Comments (3)
Is this a bug, or am I "doing it wrong"? I am simply trying to add a color to the color map at index #0.
from imagemagick6.
It might be possible that the PNG coder will remove the color unless it is used in the image. What happens when you set one of the pixels to that color?
from imagemagick6.
Haven't tried, but it is not usable workaround, as then you need to have a pixel you don't need in the image... :/
My use case is that I'm converting images for a paletted display system (GBA). There color No. 0 is always transparent, thus I need to add a color at palette index 0 that I don't use. My original code used was this:
Image img;
img.read("in.png"); //<-- 8bit paletted file, 255 colors
// read palette
std::vector<Color> colorMap;
for (size_t i = 0; i < img->colorMapSize(); ++i) {
colorMap.push_back(img->colorMap(i));
}
img.colorMapSize(img.colorMapSize() + 1); //<--after this this the color map is actually 1 entry bigger
colorMap.push_back(Color("#ff00ff"));
for (size_t i = 0; i < colorMap.size(); ++i) {
img->colorMap(i, colorMap.at(i));
}
img.syncPixels();
// increase color indices in pixels
img.modifyImage();
const auto nrOfIndices = img.columns() * img.rows();
auto pixels = img.getPixels(0, 0, img.columns(), img.rows()); // we need to call this first for getIndexes to work
auto indices = img.getIndexes();
for (size_t i = 0; i < nrOfIndices; ++i) {
indices[i] = indices[i] + 1;
}
// sync and write modified image
img.syncPixels();
img.write("out.png"); //<--image written has still 255 colors
But this doesn't work either.
from imagemagick6.
Related Issues (20)
- File saved in RAW format has JPEG data HOT 1
- convert monochrome tiff to pdf produces invalid pdf HOT 2
- Problems when convert PDF to png some characteres are converted on black boxes
- librsvg delegate is available but not used HOT 2
- Cannot build with OpenCL HOT 3
- delegates.xml broken for dng:decode HOT 3
- Assertion _cairo_status_is_error (status) failed. HOT 2
- Fail to build: test fail timeout HOT 5
- `SetMagickSecurityPolicy` always fails HOT 6
- `time` security policy is incompatible with long-running processes HOT 1
- regression when comparing images with alpha to image without alpha with -alpha off HOT 2
- regression completely disabling -quality parameter for webp HOT 2
- ImageMagick requires libtiff 4.0.3+ since 6.9.12-19 HOT 1
- Resizing TIFF, realloc(): invalid next size HOT 3
- 6.9.12-98: Tests are mass failing HOT 1
- Negative x values dont work HOT 1
- Mogrify fails when converting a folder in NAS HOT 2
- fft + ift roundtrip fails to produce a similar output image HOT 1
- Caption: fails to produce output on strings length higher than 800 characters HOT 1
- I get a LockSemaphoreInfo, when i just initialize ImageMagick++ HOT 1
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 imagemagick6.