It is not the fastest method but it is reasonably quick bearing in mind it is once removed from the driver. It only applies to monochrome displays.
The functions are overloaded so that you can either define the area to be written by Width and Height or by reference to an image. This is useful if you want to erase a previously written image or invert it to form a highlight.
Code: Select all
{
****************************************************************************
* Name : WriteArea *
* Purpose : BitBlit solid color to GLCD at pixel location x,y *
* : image defined in pW by pW, mode by pMode and pColor *
* : NOTE: for drivers with ReadByte and WriteByte implemented *
****************************************************************************
}
Sub WriteArea(pX, pY, pW, pH As TXY, pMode As Byte, pColor As Byte)
Dim x,y,Width,Height As Byte
Dim LastPen As TPen
Dim Index As Word
LastPen = Pen
Pen.Mode = pMode
// byte aligned bit blit...
Index = 4
y = pY
Height = pH/8
While Height > 0
x = pX
Width = pW
While Width > 0
WriteImageByte(x,y,pColor)
Inc(Index)
Inc(x)
Dec(Width)
Wend
Inc(y,8)
Dec(Height)
Wend
// non byte aligned bit blit...
pY = y
pH = pH Mod 8
If pH > 0 Then
x = pX
Width = pW
Pen.Color = pColor.0
While Width > 0
Height = pH
y = pY
While Height > 0
SetPixel(x,y)
Dec(Height)
Inc(y)
Wend
Inc(Index)
Dec(Width)
Inc(x)
Wend
EndIf
Pen = LastPen
End Sub
{
****************************************************************************
* Name : ClearArea(OVERLOAD) *
* Purpose : BitBlit solid color to GLCD at pixel location x,y *
* : image size defined in pW by pH or byRef to pImage *
* : NOTE: for drivers with ReadByte and WriteByte implemented *
****************************************************************************
}
Public Sub ClearArea(pX, pY, pW, pH As TXY)
WriteArea(pX,pY, pW, pH, cmCopy, $00)
End Sub
Public Sub ClearArea(px, pY As TXY, ByRefConst pImage() As Byte)
WriteArea(pX, pY, pImage(1), pImage(2), cmCopy, $00)
End Sub
{
****************************************************************************
* Name : SetArea (OVERLOAD) *
* Purpose : BitBlit solid color to GLCD at pixel location x,y *
* : image size defined in pW by pH or byRef to pImage *
* : NOTE: for drivers with ReadByte and WriteByte implemented *
****************************************************************************
}
Public Sub SetArea(pX, pY, pW, pH As TXY)
WriteArea(pX, pY, pW, pH, cmCopy, $FF)
End Sub
Public Sub SetArea(pX, pY As TXY, ByRefConst pImage() As Byte)
WriteArea(pX, pY, pImage(1), pImage(2), cmCopy, $FF)
End Sub
{
****************************************************************************
* Name : InvertArea (OVERLOAD) *
* Purpose : Invert image on GLCD at pixel location x,y *
* : image size defined in pW by pH or byRef to pImage *
* : NOTE: for drivers with ReadByte and WriteByte implemented *
****************************************************************************
}
Public Sub InvertArea(pX, pY, pW, pH As TXY)
WriteArea(pX, pY, pW, pH, cmXOR, $FF)
End Sub
Public Sub InvertArea (px, pY As TXY, ByRefConst pImage() As Byte)
WriteArea(pX, pY, pImage(1), pImage(2), cmXOR, $FF)
End Sub
#Ifndef GLCD_SETIMAGE
#IfDef GLCD_PIXEL_01
#EndIf
#EndIf
Hope its useful.