-
Notifications
You must be signed in to change notification settings - Fork 1
Allow draw png images in 8 bit character format #16
Comments
I think converting images to character data should be a separate tool, not an extension; the extension can just read the character data. |
guys, this is great idea! A had searching for such tool in past, but found nothing. Maybe dumb question, but (undestood 8bit colors for older systems) why not do 24bit colors too? |
It's not really 8-bit (256 colours), but 4-bit (16 colours; foreground and background combined make eight bits). The "terminal" has 256/24-bit colour, so porting catimg would be a better idea (it already supports transparency, too, and the higher resolution would work no problem). ANSICON reduces 24-bit to 4-bit, so that could be used/included for older systems (although perhaps bit8img with its stippling might be better). |
I think is better have the resources as png files instead of non standard binary format. This allow more easy edit. Will be nice also allow save the processed (downsampled) image to png, for iterate the edition for get the proper result (somethink like pixel art edit). About create a separate tool, it will allow use other languages like C++. About port catimg I'm not sure. |
I prefer get the logic instead of add ansicon as a dependency to the project. |
So not only do you want to read png, you want to write png, as well. Bit8img is 104k, which will double the size of EB. Don't know how big catimg is, but I can't imagine it being much different.
Then you'll have to write it yourself or find someone else, because I'm not doing it. Having image processing in EB is going way beyond what it should be doing. |
Is 104 KB because is C++ that uses a lot of crt. Also uses CImg.h (2,75 MB of code). On the other hand spng.c + spng.h are only (120 KB).
I understand, not problem. I will try do it first before ask for help. I'm sure that doing it in C will result in a tiny size result. About "a image processing" maybe for optimize the things, EB can only read images and the read and write can be a separate tool. I'm not sure. |
I am sure - EB should only read character images, a separate tool should create them. |
Use libspng requires zlib, that is other complexity for compile. |
Bear in mind spr does not support 8/24-bit colour, unless you're going to create another format. Hm, might not be a bad idea: use |
I write an initial png reader with Go and the size is 2.3 MB, too much for me. Finally I compiled the example of libspng with proper crt optimization and the size for x86 is 78 KB. |
About the 24 bit colour, the example of Microsoft show it using Bash. Is possible display more than 16 colors in cmd ? |
I believe GDI+ has a redistributable for 2K and stb_image has defines to remove unwanted formats. The terminal escape sequences provide a fixed palette of 256 colours (16 ANSI colours, 216 6x6x6 RGB cube and 24 grey scale), as well as RGB colours; these are supported by ConHost since 10.0.15063.0, I think. It took ages to get those percents right, I'll have to see if I can do something about it. |
Jason the example is really nice. Thus print 24 bit color is only possible through escape sequences?.
I think that this is the approach. thus is needed defined a new format (not spr) that support correctly 24 bit. Maybe something like CHAR_INFO but with a Attributes field using DWORD. |
I found this quote that will not be a new api for print using 24 bit colors:
|
And I found microsoft/terminal#292 suggesting that there's not going to be an API to read it, either, but, if we're lucky, possibly a file. The new format would contain a literal string which is literally echoed - that's why Sixel graphics might appear one day, which would be nice. I fixed the percent problem. |
Maybe have a format that store the "pixel character representation" in CHAR_INFO and with a literal string for escape sequence ?
Thus, I think will be very practical have a buffer with the data of the console in our own format (the most updated possible). This is also the key I think for support "transparent characters", we use the character from our buffer. |
From the docs: "The total size of the array must be less than 64K." How big an image do you want? 16K allows for 128x128 or about 160x100, which seems plenty big enough to me. An opaque image could use |
Really cool. It doesn't matter that it doesn't work on windows terminal. I really want this feature in EB. |
About the character image mode, I not agree on create a external tool for convert to EB format, this are my reason. I want support only 24 bit png, using this: https://github.com/apankrat/lpng Is not need support other format than png 24 bit. |
About the IMAGE extension: for Windows Terminal what about use a predefined or hardcoded font like "Consolas"? |
I implemented a light version of read png using a library called upng (https://github.com/elanthis/upng). The extension using this increases the size of the dll 10 KB only. The branch is: |
The trick is to read the documentation, where it will say if the window is minimized anything drawn by GDI is lost. Same if you scroll, or maximize, or change size.
What are the reasons for not using it? People have their images in other formats. So because you want to do it in EB, and you want to keep it small, you want every other batch file writer to convert their images to 24-bit PNG (and use pngout to make it smaller). If you must process images directly, use GDI+, it's hardly any size at all.
Windows Terminal uses the font defined in its settings, totally overriding the console properties. Besides which, GDI simply doesn't work - I think Direct2D has precedence. |
I tried it on Windows Terminal and seems when I run call |
It's not even supposed to run on WT at all ( |
I had no problem using it on WT - just did nothing. Tried Direct2D, but that did nothing, too. Looks like WT will miss out - have to wait for sixel. On 10 it looks like pressing Tab (file name completion) will also remove GDI. |
Did a force push of the |
I've added |
Jason, I agree on merge it, and create a new issue for the /V. Maybe for solve that a option can be only choose the fonts that works properly? I not understand fully the issue. |
Here's my version of |
Jason, the result is awesome, much better than the original bit8img. Please we can merge it to EB? |
I am not going to support a 1x1 font, use I don't think EB should change the palette automatically, though, so there's another extension. I've also updated With 10 we can forget about the palette and have proper RGB images. |
Feature implemented nicely by @adoxa in the extension called |
I want allow draw png images in 8bit character format in the console.
The idea is this next:
call @data sun.png
This will load the data of the png image, convert to 8bit and save in an special storage, in this case "sun" (extracted from the name)
Subsequent calls to
call @data sun.png
will no process again, if it found that the "sun" key is found in the storage it will no save anything new.call @data /D sun.png
remove from the storage.
Then, a new extension called
@draw
will allow draw that images to the console.call @draw sun [row] [column]
Also will be possible a extension called
@canvas
that will allow create an image (not properly an image, a strcuture that represent the data) transparent or filled with some color. Thus you can draw more than one image to the canvas, and after that call@draw
to the canvascall @canvas mycanvas 100 100
call @paint mycanvas sun [row] [coord]
call @draw mycanvas
I prefer the png because support alpha color, thus in the conversion is possible support transparent "pixels" that will use the current background of the structure.
I think the intermediate format structure should be something like an
CHAR_INFO
structure array with aCOORD
for indicate the size. For the transparent "pixels" the character 0 can be used as convention.Here attached an example of draw a 24 bit image as 8 bit image.
A user called KKziomek write a tool similar to this called bit8img
BIT8IMG Tool v1.0 build 003.zip
But is uses C++, an uses bitmap, that not support transparency.
I prefer png because allow compression an support transparency.
I thinked in use a library called libspng for do the task.
This tool will allow draw nice menus, or backgrounds for the console.
The text was updated successfully, but these errors were encountered: