one bit transparency - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions) +--- Thread: one bit transparency (/Thread-one-bit-transparency) Pages:
1
2
|
one bit transparency - bitrat - 11-05-2022 Hi, in CorelDraw, it is (was?) possible to render a one bit (b&w) image as an arbitrary solid colour for black and transparent for white. Note that this involved no blending or increase in bit width of the image. I'm trying to do the same thing with GIMP and Inkscape (which sadly lacks this incredibly useful and probably not too difficult to implement feature). So far all I've managed is an RGBA exported to png with a constant RGB and a high contrast alpha. It seems to be impossible to prevent some degree of 'anti-aliasing'. I can import this into Inkscape and lay it over a coloured background, but when I export it, it's alpha blended, even though I didn't ask for that. Again, it seems to be impossible to prevent 'anti-aliasing'. Also, for some reason, Inkscape adds a transparency checker pattern to the background (which is not visible in the edit window). Surely there's a way to create a one bit transparency in GIMP and render it in colour in Inkscape, then export it without alpha or checkers! UPDATE: I've figured out how to do this in GIMP, but I'd still really like to know if and how I can create and export a one bit colour + transparency image. Heelp me.... heelp meee... pleeezzzzz..... bitrat RE: one bit transparency - denzjos - 11-05-2022 I think this is what you want : Use Colours / Threshold (use the sliders to optimase result) Select the black or white with the 'Select by Colour Tool' Delete the selection Image / Mode / Indexed (Use black and white (1-bit) palette) The checkerboard is only gimp tranparent background, it is not visible on the exported image. If you make a screendump, then it is visble on the result image because you get all the visible information as you see it on the screen. [attachment=8970] RE: one bit transparency - bitrat - 11-05-2022 (11-05-2022, 09:16 AM)denzjos Wrote: Image / Mode / Indexed (Use black and white (1-bit) palette) Thanks denzjos. That's a good idea to add the alpha then convert mode. I thought it solved the problem, but unfortunately it doesn't (quite) work... Here's what I do (that doesn't work).
What I want is black+transparent, rather than black+white. I'm reasonably sure there are other ways to accomplish this. Unless it's actually impossible to do with PNG, I could probably write a C program to get wiw in 5 minutes. It's effectively a black sprite and I'm fairly sure it's possible in most icon file formats. I'd also like to solve the associated Inkscape issue so, if any Inkscape aficionados out there can help, that would also be appreciated! Cheers! RE: one bit transparency - rich2005 - 11-05-2022 This has come up before see: https://www.gimp-forum.net/Thread-Export-1-Bit-PNG-with-Alpha I do not know how you get a anti-alised 8-bit palette, even with Gimp 2.10 which throws in an extra indexed entry you just get 2 Work-flow: Black-on-White image Colour-to-Alpha to make black on transparent Mode -> Indexed 1 bit. You do not say which OS you are using. If you can get a Gimp 2.8 that might work for you. [attachment=8971] ImageMagick - Same as you, I can not see any way of getting a 1 bit png out. RE: one bit transparency - bitrat - 11-05-2022 (11-05-2022, 08:40 PM)rich2005 Wrote: This has come up before see: https://www.gimp-forum.net/Thread-Export-1-Bit-PNG-with-Alpha Hi rich2005, I just found that link myself but thanks! My GIMP doesn't allow me to create a black+white (1-bit) image. Minimum is 8-bit. Every package seems determined to turn a bitmap into a grayscale at every opportunity, and to antialias screen rendering in the viewer, so it's often impossible to see whether the image itself is a bitmap or grayscale. Even the window manager is probably involved in this... Anyway, I'll update here when I've done some more experimenting. I'm using GIMP 2.10.30 on Ubuntu 18.04. Due for a system rebuild, but too much on to do it right now.. No AppImage for 2.8 I'll just need to manage with current limitations for now. Basically, I'm trying to get pixel level control over grayscale rendering using the 'newsprint' dot screen filter. It's very annoying to have this option removed, presumably based on the assumption that antialiasing and grayscale are always better.... Thanks again for the reminder to try ImageMagick, but sounds like it won't get me far... I don't want extra steps in my workflow if I can help it, but it can be a lifesaver sometimes. ____________________________ UPDATE: It looks like a PNG exported from a GIMP image created as per your suggestion is 8-bit RGB ... Code: $ identify test-1bit-alpha.png but it looks like it's 1-bit (black+alpha) under the hood, padded to 8-bits just to use extra disk space or some other misbegotten 'optimisation' ... Code: $ identify -verbose test-1bit-alpha.png I may get there yet... Cheers, bitrat RE: one bit transparency - Ofnuts - 11-06-2022 (11-05-2022, 10:34 PM)bitrat Wrote: Hi rich2005, There is a difference between the image in Gimp and was it exported (otherwise you wouldn't export JPEG from 32-bit FP images). I tried this:
[attachment=8973]
Code: 01:40:28 @ ~/ : >file /tmp/OneBPP.png RE: one bit transparency - bitrat - 11-06-2022 Thanks Ofnuts. I'm getting close. If only I could replace those white pixels with transparent, and persuade the whole thing to render from Inkscape, in colour ... If I render the bw image from Inkscape using 'crisp-edges- render mode, it doesn't add gray, levels but this doesn't work for the one with alpha. I can do wiw in GIMP so all good. Thank you. RE: one bit transparency - Ofnuts - 11-06-2022 (11-06-2022, 07:04 AM)bitrat Wrote: Thanks Ofnuts. I'm getting close. If only I could replace those white pixels with transparent, and persuade the whole thing to render from Inkscape, in colour ... Once you have a two-color colormap, with GIF it is just a matter of marking one of the colors as transparent (with PNG it is different, opacity is a mask). But if it is consumed by Inkscape, why do you care about the internal representation? And what is your final target image format? RE: one bit transparency - rich2005 - 11-06-2022 Quote:..My GIMP doesn't allow me to create a black+white (1-bit) image. Minimum is 8-bit... Not true, just the way IM reports. You can always compare file sizes. This the same image, exported as a 1bit indexed file and then exported as 8bit RGBA. [attachment=8975] Edit: If you want IM to report as 1 bit then the same indexed - 1 bit image exported as a tiff. [attachment=8976] That is me out, best of luck RE: one bit transparency - bitrat - 11-07-2022 (11-06-2022, 08:49 AM)Ofnuts Wrote: But if it is consumed by Inkscape, why do you care about the internal representation? And what is your final target image format? Many years ago, CorelDraw could import 1-bit black+white images and render each pixel with either of two arbitrary colours (defined as RGBA, HSV, Pantone, or whatever). The arbitrary colours were not encoded in the imported bitmap. CorelDraw used one attribute (pen) to set the colour of the 'black' pixels, and another (fill) to set the 'white' ones. On import, CorelDraw rendered black+white as black+transparent by default. By overlaying and aligning multiple same size bitmaps, it was possible to control the colour and transparency of each pixel in the image. With care, different sized bitmaps could be overlaid, but I forget how I registered them. I'm trying to accomplish something similar. (11-06-2022, 11:29 AM)rich2005 Wrote: Not true, just the way IM reports. You can always compare file sizes. This the same image, exported as a 1bit indexed file and then exported as 8bit RGBA. Thanks rich2005, you've given me some good ideas. File size is somewhat obscured by compression. Export to BMP is uncompressed by default, but it doesn't do alpha. Can't seem to find any settings to disable compression in other formats. Also, tif export of my source image is buggy in my GIMP. All that said, I don't think spelunking image formats will solve my problem. As per above, what I need is to:
I've figured it out! I can do it with layer masks. I was too focused on bit width, but I just need to copy my 1-bit bitmaps onto the masks. EXCEPT.... The advantage of using CorelDraw or Inkscape is that they render colours subtractively (like inks), while GIMP's is additive (like prisms). Maybe something like the layer mode set to Subtract would work. That doesn't do what I want, but there are lots of modes. Can anyone suggest a way to have red, green and blue add up to black, not white? |