Ascii Art coloring


I working on an image to Ascii Art project and so far so good, though a bit too slow when it comes to rather large images, but thats another issue. Anyway I’m trying to figure out how to color the text , approx to that of the image. So far it doesn’t color it. I may not have this right. :neutral_face:

var st as  new StyledText

For y = 0 To image.Height - 1
  For x = 0 To image.Width - 1
    c = image.RGBSurface.Pixel(x,y)//get  color from image
    nextColor =image.RGBSurface.Pixel(x+1,y)

//do some calculations , brightness &  index here

    textcount = textcount +1 // count the text so far for current color
    St.Text = St.Text +asciiChars.Mid(index + 1, 1)
    if c <> nextColor     then //if next color is different, color the text  so far to  C
      st.TextColor (start, textcount) = c
      start = x 
      textcount = 0
    end if
  Next x
  start = start + Y

  St.Text =St.Text + EndOfLine

Next y

st.FontName(0,st.Text.Length) = "Courier New"
st.Size(0,st.Text.Length) = 4
TextArea1.StyledText = st

Thanks! :grin:

These lines are the problem

St.Text = St.Text +asciiChars.Mid(index + 1, 1)
St.Text =St.Text + EndOfLine

As soon as you set st.Text = anything, it resets all the styles. You should probably make each color a separate StyleRun and append them to TextArea1.StyledText individually.

Hello for Text In PictureColor
I choose another way
about copy mask
see example

Ah I see. I haven’t done much with Styledtext to this extent before. I’ll have to look into that.


Thank you. I’ll take a look when I get some time.