This is only minor programming related - it has much more w / colors features and their presentation.
I am working on a very low level application. I have an array of bytes in memory. These are characters. They were processed by smoothing: they have values from 0 to 255, 0 are completely transparent and 255 are completely opaque (alpha, if you want).
I had a problem developing an algorithm to render this font. I do the following for each pixel:
// intensity is the weight I talked about: 0 to 255 intensity = glyphs[text[i]][x + GLYPH_WIDTH*y]; if (intensity == 255) continue; // Don't draw it, fully transparent else if (intensity == 0) setPixel(x + xi, y + yi, color, base); // Fully opaque, can draw original color else { // Here the tricky part // Get the pixel in the destination for averaging purposes pixel = getPixel(x + xi, y + yi, base); // transfer is an int for calculations transfer = (int) ((float)((float) (255.0 - (float) intensity/255.0) * (float) color.red + (float) pixel.red)/2); // This is my attempt at averaging newPixel.red = (Byte) transfer; transfer = (int) ((float)((float) (255.0 - (float) intensity/255.0) * (float) color.green + (float) pixel.green)/2); newPixel.green = (Byte) transfer; // transfer = (int) ((float) ((float) 255.0 - (float) intensity)/255.0 * (((float) color.blue) + (float) pixel.blue)/2); transfer = (int) ((float)((float) (255.0 - (float) intensity/255.0) * (float) color.blue + (float) pixel.blue)/2); newPixel.blue = (Byte) transfer; // Set the newpixel in the desired mem. position setPixel(x+xi, y+yi, newPixel, base); }
Results, as you can see, are less desirable. This is a very large image, on a 1: 1 scale, it looks like the text has a green “aura”.

Any idea on how to calculate this correctly would be greatly appreciated.
Thank you for your time!
source share