これはほんのわずかなプログラミング関連であり、色とその表現に関してもっと多くのことを行う必要があります。
私は非常に低レベルのアプリに取り組んでいます。メモリにバイト配列があります。それらはキャラクターです。それらはアンチエイリアシングでレンダリングされました。値は 0 から 255 で、0 は完全に透明、255 は完全に不透明 (必要に応じてアルファ) です。
このフォントをレンダリングするためのアルゴリズムを考え出すのに苦労しています。各ピクセルに対して次のことを行っています。
// 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's 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);
}
ご覧のとおり、結果は望ましいものではありません。これは非常に拡大された画像です。1:1 の縮尺では、テキストに緑色の「オーラ」があるように見えます。
これを適切に計算する方法についてのアイデアは大歓迎です。
御時間ありがとうございます!