Open GoogleCodeExporter opened 8 years ago
So bitmap masking does the work,but I don't know how it works so far
for yellow
graylevel = ((glyphBitmap[i][j] & 0x000000ff) << 8)
And maybe to produce other color we need to do bitwise shifting.
Original comment by sant...@braindigit.com
on 25 Jan 2013 at 4:17
folowing works for colors.
public void drawGlyph(int glyphBitmap[][], int x, int y) {
if (glyphBitmap == null) {
return;
}
int height = glyphBitmap.length;
if (height == 0) {
return;
}
int width = glyphBitmap[0].length;
Bitmap tempBitmap = Bitmap.createBitmap( width, height, Bitmap.Config.ARGB_8888);
int rVal = Color.red(m_nTextColor);
int gVal = Color.green(m_nTextColor);
int bVal = Color.blue(m_nTextColor);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
int bitmapValue = glyphBitmap[i][j];
if (bitmapValue == 0)
tempBitmap.setPixel(j, i, Color.TRANSPARENT);
else {
float bitmapFactor = ((float)(bitmapValue & 0xFF)) / 255.0f;
tempBitmap.setPixel(j, i, Color.argb(255,
(int)(bitmapFactor * rVal), (int)(bitmapFactor * gVal),
(int)(bitmapFactor * bVal)));
}
}
}
Original comment by rgubb...@gmail.com
on 25 Jan 2013 at 3:52
[deleted comment]
@rgubb:
Thanks a lot ,your method works greatly for adding colors to EditIndicText.
But I do have a question
on black background,the textColor seems to work fine
but on white background,I couldn't see the same crispness of color as displayed on black background.To work
For black background
float bitmapFactor =((float)(bitmapValue& 0xFF)/255.0f
And for white background I have done
float bitmapFactor =((float)(bitmapValue& 0xFF);
But the quality of color is not so vibrant as of text color displayed on black background.
Original comment by sant...@braindigit.com
on 27 Jan 2013 at 9:28
Attachments:
sant...,
I think the problem is same as what we faced early on. Check if the letters are
hazy (or blurred) if you didn't do any color factoring. If so, try the
following.
In the loop replace the first line
int bitmapValue = glyphBitmap[i][j];
by
int bitmapValue = 255 - glyphBitmap[i][j];
and do the rest as it is now. that might solve the problem.
Original comment by rgubb...@gmail.com
on 27 Jan 2013 at 10:50
[deleted comment]
@rgubb:
Yes the issue is same as you explained on http://code.google.com/p/indic-text-renderer/issues/detail?id=8 i.e. the text being fuzzy on white background. And I haven't done any color factoring,just followed the steps provided by you.And the solution you have provided
In the loop replace the first line
int bitmapValue = glyphBitmap[i][j];
by
int bitmapValue = 255 - glyphBitmap[i][j];
doesn't do any good i.e. the text comes in fuzzy manner
And last request to you,could you point me on how to learn bitmap masking,pixel
concept and coloring to pixel,so that I might figure whole thing on my own
Original comment by sant...@braindigit.com
on 28 Jan 2013 at 5:45
[deleted comment]
sant...
To learn pixels, their coloring etc. please refer to any basic tutorial or text
book on image processing. I dont have any reference handy at this time.
On blurred chars displayed, please check to make sure your JNI is being built
everytime you change the C file. Also try removing the following lines in the
inner loop. This causes the black to become transparent and hence reflect the
white background.
if (bitmapValue == 0)
tempBitmap.setPixel(j, i, Color.TRANSPARENT);
Original comment by rgubb...@gmail.com
on 28 Jan 2013 at 7:43
@rgubb
I have done as you stated
int textColor =Color.BLUE;
//if (glyphBitmap[i][j] == 0) {
//tempBitmap.setPixel(j, i, Color.WHITE);
// } else {
int bitmapValue =glyphBitmap[i][j];
float bitmapFactor = (float)((bitmapValue & 0xff))/255.0f;
tempBitmap.setPixel(j, i, Color.argb(255,
(int) (bitmapFactor*redValue),
(int) (bitmapFactor*blueValue),
(int) (bitmapFactor*greenValue)));
//}
And the text comes in desired blue color but with black background.Right now I
am not changing any C (complex-script-rendering) file.
See first text
And when I do
int bitmapValue =255- glyphBitmap[i][j];
I see black text with blue background.(see second text)
Original comment by sant...@braindigit.com
on 28 Jan 2013 at 8:32
Attachments:
Original issue reported on code.google.com by
sant...@braindigit.com
on 24 Jan 2013 at 8:22