LCDInfo.com

http://www.lcdinfo.com
It is currently Thu Nov 21, 2024 22:57

All times are UTC + 2 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Feb 28, 2003 5:37 
Offline

Joined: Tue Feb 25, 2003 2:55
Posts: 2
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!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 28, 2003 9:20 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
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.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 28, 2003 15:23 
Offline

Joined: Tue Feb 25, 2003 2:55
Posts: 2
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.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 01, 2003 21:49 
Offline

Joined: Sun May 05, 2002 22:05
Posts: 2063
Location: Lappeenranta, Finland
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.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 02, 2003 1:39 
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 :)


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group