LCDInfo.com
http://forum.lcdinfo.com/

Help! Cant figure how how to draw a bitmap to Noritake 800
http://forum.lcdinfo.com/viewtopic.php?f=9&t=158
Page 1 of 1

Author:  xtremeRS [ Fri Feb 28, 2003 5:37 ]
Post subject:  Help! Cant figure how how to draw a bitmap to Noritake 800

I have code to write an entire bitmap, but I need to be able to draw a bitmap at a certain position on the screen, i.e.:

DrawBmp(Pic.hDC, 80, 22)

I've got some code that kind of works, but it only works in certain cases.

Thanks!

Author:  Henri [ Fri Feb 28, 2003 9:20 ]
Post subject: 

I don't have code to just paste here but maybe if you posted your code and the situations where it works and where it doesn't.

Author:  xtremeRS [ Fri Feb 28, 2003 15:23 ]
Post subject: 

well, lol, I kinda messed up the code and now it doesnt work at all..... I basically copied the code from Proporskis VB Blinkenlights app, and modified it some. I'm sure I'm making this way too complicated. This codes does not work (at least I dont think it does, I'm at work right now, lol) If it did work, it worked with a 36wx9h image at position 5,5:

Code:
Public Sub DrawBMPXY(hPic As Long, x As Integer, y As Integer, height As Integer, width As Integer)
    Dim iData As Integer
    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
    Dim intCtr As Integer
    Dim intStartRow As Integer
    Dim intEndRow As Integer
    Dim intYOffset As Integer
    Dim intYStart As Integer
    Dim intYEnd As Integer
   
    For i = 0 To 7
        If (8 * i) > y Then
            intStartRow = i - 1
            Exit For
        End If
    Next i
   
    For i = 7 To 0 Step -1
        If (8 * i) < (y + height) Then
            intEndRow = i
            Exit For
        End If
    Next i
   
    intYOffset = 0
   
    For i = intStartRow To intEndRow '0-7 = 8 Display Rows
        'Change Write Position - X
        Call ChangeWritePositionX(x)
     
        'Change Write Position - Y
        Call ChangeWritePositionY(i)
        For j = x To (x + width) - 1
            iData = 0
           
            If i = intStartRow Then
                intYStart = (8 * (intStartRow)) + y
            Else
                intYStart = 1
            End If
           
            If i = intEndRow Then
                intYEnd = (y + height) - (8 * intEndRow) - 1
            Else
                intYEnd = 8
            End If
           
            'Code that tries to draw any size bitmap to any location
            For k = 1 To 8
                If (k >= intYStart) And (k <= intYEnd) Then
                    'Debug.Print (j - x) + 1 & ", " & (i * 8 + k - (intYStart - 1) - intYOffset) & ": " & GetPixel(hPic, (j - x) , i * 8 + (k-1) - (intYStart - 1))
                    If GetPixel(hPic, (j - x) , (i * 8 + (k-1) - (intYStart - 1) - intYOffset)) = 0 Then
                        iData = iData + 2 ^ (k - 1)
                    End If
                End If
            Next k
           
            'Code to draw a 128x64 file
            'For k = 1 To 8
            '    If iData And (2 ^ (k - 1)) Then
            '        picTmp.PSet ((j - x) + 1, (i * 8 + k - (intYStart - 1) - intYOffset)), vbBlack
            '    End If
            'Next
           
           
            WriteData iData
        Next j
        intYOffset = intYOffset + (intYStart - 1)
    Next i
End Sub


Using code similar to the above, I was able to draw an image at any x position, but when y was greater than 7, it would fail.

Author:  Henri [ Sat Mar 01, 2003 21:49 ]
Post subject: 

Ok, I tried to look at that code few times but somehow VB is just so hard to keep up with ;)

Are you aware that you can only set the y position at every 8 pixel ? Like 0,8,16,24,32,... as one byte is 8 pixels high in the display memory. So y position 1 is 8th pixel and 2 is 16th pixel.

Author:  Guest [ Sun Mar 02, 2003 1:39 ]
Post subject: 

Henri wrote:
Ok, I tried to look at that code few times but somehow VB is just so hard to keep up with ;)

Are you aware that you can only set the y position at every 8 pixel ? Like 0,8,16,24,32,... as one byte is 8 pixels high in the display memory. So y position 1 is 8th pixel and 2 is 16th pixel.


Yes, I know that that, and thats really the main problem. Is there any way to read the status of one of those locations from the display? When I had the code semi-working, and I drew an image at pixel location 5,5 (GRAM location 5, 0), it would clear pixels 1, 2, 3, and 4 since the image was not being placed there. In order to correctly draw the image without overwriting over info on the screen that falls in the GRAM location, I'd have to keep track of every byte in GRAM, unless I could read the byte before I wrote the image out...

After writing this paragraph, I think I may have figured something out. I'll post the code if I get it working :)

Page 1 of 1 All times are UTC + 2 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/