Me again...
Hoping that someone can help me here again:
I'm on replacing the font used in my display with PNG's and it worked good so far, except one thing: the volume.
I have no clue how i can do it with the volume...
I used the format fb.Volume.toFixed(2).
Here is the working example code for playback time:
function TimeImage() {
this.image = gdi.CreateImage(120, 20);
this.currentTime = "";
this.init = function(time) {
gr = this.image.GetGraphics();
this.drawDigit(time, 0, 0);
this.drawDigit(time, 1, 0);
g_rowImage && gr.DrawImage(g_rowImage, 36, 0, 6, 20, 234, 0, 6, 20);
this.drawDigit(time, 3, -12);
this.drawDigit(time, 4, -12);
g_rowImage && gr.DrawImage(g_rowImage, 78, 0, 6, 20, 234, 0, 6, 20);
this.drawDigit(time, 6, -24);
this.drawDigit(time, 7, -24);
this.currentTime = time;
this.image.ReleaseGraphics(gr);
}
this.draw = function(time) {
if (this.currentTime == "") this.init(time);
else {
gr = this.image.GetGraphics();
this.drawDigit(time, 0, 0);
this.drawDigit(time, 1, 0);
this.drawDigit(time, 3, -12);
this.drawDigit(time, 4, -12);
this.drawDigit(time, 6, -24);
this.drawDigit(time, 7, -24);
this.currentTime = time;
this.image.ReleaseGraphics(gr);
}
}
this.drawDigit = function(time, index, offset) {
var digitValue = time.charAt(index);
if (this.currentTime == null || this.currentTime == "" || digitValue != this.currentTime.charAt(index)) {
var xoffset = index * 18 + offset;
gr.FillSolidRect(xoffset, 0, 18, 20, ui_backcol);
drawSquares(gr, 2, 1, xoffset, 0, 18, 20);
g_rowImage && gr.DrawImage(g_rowImage, xoffset, 0, 18, 20, digitValue * 18, 0, 18, 20);
}
}
}
var g_timeImage = new TimeImage();
Later i call in on_paint:
var t_fmt = t_rem ? info.Remain : info.Elapse;
g_timeImage.draw(t_fmt);
gr.DrawImage(g_timeImage.image, Math.floor(ww / 2.55), 30, 120, 20, 0, 0, 120, 20);
g_noTimeImage && gr.DrawImage(g_noTimeImage, Math.floor(ww / 2.55), 30, 120, 20, 0, 0, 120, 20);
And as long the g_rowImage (where all needed numbers and signs are in) is there it works really well.
So i thought i could do something similar with the volume and rewrote it to this:
function VolumeImage() {
this.image = gdi.CreateImage(168, 20);
this.curVolume = "";
this.init = function(volume) {
gr = this.image.GetGraphics();
this.drawDigit(volume, 0, 0);
this.drawDigit(volume, 1, 0);
this.drawDigit(volume, 2, 0);
this.drawDigit(volume, 3, 0);
g_rowImage && gr.DrawImage(g_rowImage, 72, 0, 6, 20, 240, 0, 6, 20);
this.drawDigit(volume, 5, -12);
this.drawDigit(volume, 6, -12);
g_rowImage && gr.DrawImage(g_rowImage, 114, 0, 18, 20, 216, 0, 18, 20);
g_rowImage && gr.DrawImage(g_rowImage, 132, 0, 36, 20, 264, 0, 36, 20);
this.curVolume = volume;
this.image.ReleaseGraphics(gr);
}
this.draw = function(volume) {
if (this.curVolume == "") this.init(volume);
else {
gr = this.image.GetGraphics();
this.drawDigit(volume, 0, 0);
this.drawDigit(volume, 1, 0);
this.drawDigit(volume, 2, 0);
this.drawDigit(volume, 3, 0);
this.drawDigit(volume, 5, -12);
this.drawDigit(volume, 6, -12);
this.curVolume = volume;
this.image.ReleaseGraphics(gr);
}
}
this.drawDigit = function(volume, index, offset) {
var digitValue = volume.charAt(index);
if (this.curVolume == null || this.curVolume == "" || digitValue != this.curVolume.charAt(index)) {
var xoffset = index * 18 + offset;
gr.FillSolidRect(xoffset, 0, 18, 20, ui_backcol);
drawSquares(gr, 2, 1, xoffset, 0, 18, 20);
g_rowImage && gr.DrawImage(g_rowImage, xoffset, 0, 18, 20, digitValue == " " ? 216 : digitValue * 18, 0, 18, 20);
}
}
}
var g_volumeImage = new VolumeImage();
furthermore:
function pad_right(x, y, z) {
z || (z = ' ');
return x.length < y ? z.repeat(y - x.length) + x : x
}
And in on_paint:
var vol = fb.Volume.toFixed(2) + " db";
g_volumeImage.draw(pad_right(vol, 10));
gr.DrawImage(g_volumeImage.image, ww - 194, 30, 168, 20, 0, 0, 168, 20);
But always get script errors (overflow in the g_rowImage line in this.drawDigit part)...
Does anybody have a clue why ones working ones not?
I guess it may be the "-" before the volume?
How could i get rid of?
Btw. all other codes (for tracknumber, totaltracks and bitrate) i rewrote from the time code works well too.
Only the volume will not work...
Edit:
Oh, i forgot...
This is one of the rowImages i use (this one in red):