Image to Color/Colour ASCII Art Conversions 10

2006 is try the stuff people keep bugging me about year. So… I was getting nowhere speeding up the variable width conversions, and decided to have a go at colouring the output.

Good news: Easy to do, and creating the array of Colors is fast.
Bad news: Displaying it in a Rich textbox is really slow. It’s looping through the text, selecting each character and setting the SelectionColor and it’s so slow you can see it work on each character.

The output is also not particularly great. The whole reason the normal black and white conversions work is that each character represents a grayscale value. In a colour conversion, every character needs to represent a solid pixel and then be coloured to the Color value. Basically the ramp, brightness/contrast and levels of the output image do not matter.
Even if this gets sorted out, I think this is something that I won’t be able to implement until I’ve written a control to replace the textbox, and that’s going to be difficult. The save as an image code will also need to be totally rewritten.

In other news, I really want to add some extra content about the program to this website (features, manual, output gallery etc), so I’m thinking about moving from this blog into a CMS. I’m also trying out some google adverts for a few weeks to see if they can help pay for the site. It sucks, but that donation button was just wasting space.

10 thoughts on “Image to Color/Colour ASCII Art Conversions

  • Dwayne

    Colour ASCII would be great. I already use a search replacement of your results to create a sort of greyscale colour image to heighten the black and white text. Going full colour would be great! Although, If had a choice of one over the other it would be variable width ascii art.

    Personally, I think it’d be great if you had a box to tick to go variable width or colour. I can see how both would be nightmares trying to integrate alongside such a rapidly processing monospace generation.

    I assume the variable width gen would be quicker on less valid characters (fewer characters to cycle?)? By default, I use 12 characters in Auto. I find they produce the best results.

    The Google Ads idea won’t hurt. People seem to hate users saying that they’ll donate and never do, so I won’t say that. I’m sure many people are good intentioned but never donate. I guess the only guarantee you can get is to seek other sources.

  • Jonathan

    It looks like variable width conversions will be much easier to put in. It’s down to 0.25 seconds, and I know there are a lot of unnecessary calculations being done, I just have to work out a more efficient way of doing it.

    On the other hand, the only thing stopping colour conversions is just how slow it is to set the colour of each character in a RichTextBox control.

  • Dwayne

    Here’s an idea concerning variable width, it probably won’t help since I know nothing of the complexity of the program. BUT, would it be possible for the program to figure out the effective characters before looping through the characters? I think I counted about 24 utilised in your generation (I might be wrong, I didn’t look extensively).

  • Dwayne

    I have been getting this error quite frequently on my Windows ’98. Don’t know whether it’s resource related or related to the functioning under 2.0. I think it happens when selecting a region, maybe after loading up a second picture. At least that’s how it’s crashed just now.

    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.DivideByZeroException: Attempted to divide by zero.
    at JMSoftware.AsciiGeneratorDotNet.FormConvertImage.UpdateHeight()
    at JMSoftware.AsciiGeneratorDotNet.FormConvertImage.UpdateValues()
    at JMSoftware.AsciiGeneratorDotNet.FormConvertImage.pbxMain_SelectionChanged(Object sender, EventArgs e)
    at JMSoftware.CustomControl.JMSelectablePictureBox.set_SelectedArea(Rectangle value)
    at JMSoftware.CustomControl.JMSelectablePictureBox.OnMouseMove(MouseEventArgs e)
    at System.Windows.Forms.Control.WmMouseMove(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.Label.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    ************** Loaded Assemblies **************
    Assembly Version:
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/MICROSOFT.NET/FRAMEWORK/V2.0.50727/mscorlib.dll
    Ascgen dotNET
    Assembly Version: 1.0.2188.37776
    Win32 Version: 1.0.2188.37776
    Assembly Version:
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/
    Assembly Version:
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/
    Assembly Version:
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/

    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the section.
    The application must also be compiled with debugging

    For example:

    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.

  • Dwayne

    Continuing out of it works fine. I just found that out now (I’m so used to just exiting whenever there’s a crash, I didn’t even think to give it a try.)

  • Jonathan

    Can you work out how to recreate it? I haven’t been able to make it crash, but I’ve seen a bug which might be related where you use ctrl-L while selecting something.

  • Dwayne

    Just played around with it for all but 30 seconds, and bingo. I had an image loaded up, started playing around with the selection area, done nothing; flicked between picture and ASCII tabs, and I loaded up a second image and got started selecting and got the error again. And again, continuing out of it was fine.

    Recreating it again is not working. Maybe just coincidence? I’ll try and replicate it again later on, on reboot.

  • Dwayne

    The ratioing is broken after you continue out of the error. I think everything generates in a square. I couldn’t get CTRL-L to mess it up. Also, it didn’t seem to get triggered by a double-click, just the area selection.

Comments are closed.