Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Can Johnny5 do rotated text?  (Read 1677 times)

0 Members and 1 Guest are viewing this topic.

Spartan

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 112
  • Last login:December 02, 2009, 07:09:38 pm
  • I like stuff!
    • The Municade
Can Johnny5 do rotated text?
« on: September 22, 2006, 05:25:07 pm »
...specifically for dual control panels on cocktail tables?

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19428
  • Last login:Today at 01:14:11 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Can Johnny5 do rotated text?
« Reply #1 on: September 22, 2006, 11:05:17 pm »
Nope, not yet. 

Spartan

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 112
  • Last login:December 02, 2009, 07:09:38 pm
  • I like stuff!
    • The Municade
Re: Can Johnny5 do rotated text?
« Reply #2 on: September 22, 2006, 11:17:03 pm »
damn -- any plans for it?

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19428
  • Last login:Today at 01:14:11 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Can Johnny5 do rotated text?
« Reply #3 on: September 23, 2006, 11:59:33 am »
"Not yet" doesn't give you any clue?

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2943
  • Last login:August 14, 2023, 02:00:48 am
  • 0x2b|~0x2b?
Re: Can Johnny5 do rotated text?
« Reply #4 on: September 23, 2006, 07:13:05 pm »
Well, just for the "fun of it" I decided to dust out the old VB6 and try and write something that would rotate a form 90 degrees. From memory Johnny5 uses form controls like labels to draw the CP. To rotate a GDI+ created CP would be very easy using one line of code. To rotate the contents of a form with user controls it's a little more tricky. I'll paste my code here for demonstration purposes. It uses the very slow GetPixel() and SetPixel() methods as I think the Direct Memory Access routines written by BillSoo require a picture loaded using LoadPicture() but I could be wrong. Anyway, it may give you a starting point if you havn't tried it already.

The form must have AutoRedraw set to false and ScaleMode set to 3 - Pixel...

Code: [Select]
Private Declare Function BitBlt Lib "gdi32" (ByVal hDCDest As Long, ByVal XDest As Long, ByVal YDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hDCSrc As Long, ByVal XSrc As Long, ByVal YSrc As Long, ByVal dwRop As Long) As Long
Private Declare Function SetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, ByRef lpObject As Any) As Long

Dim hDCSour As Long, hBMPSour As Long
Dim hDCDest As Long, hBMPDest As Long

Private Sub Form_Load()
    ' Show form and refresh form
    Me.Show
    Me.Refresh
   
    ' Create DC's for reading & writing the pixels
    hDCSour = CreateCompatibleDC(Me.hDC)
    hBMPSour = CreateCompatibleBitmap(Me.hDC, Me.ScaleWidth, Me.ScaleHeight)
    hDCDest = CreateCompatibleDC(Me.hDC)
    hBMPDest = CreateCompatibleBitmap(Me.hDC, Me.ScaleWidth, Me.ScaleHeight)

    SelectObject hDCSour, hBMPSour
    SelectObject hDCDest, hBMPDest

    ' BitBlt the form's pixels to the source DC
    BitBlt hDCSour, 0, 0, Me.ScaleWidth, Me.ScaleHeight, Me.hDC, 0, 0, vbSrcCopy
   
    ' Rotate the pixels using slow GetPixel() and SetPixel()
    For Y = 0 To Me.ScaleHeight - 1
        For X = 0 To Me.ScaleWidth - 1
            Dim Col As Long
            Col = GetPixel(hDCSour, X, Y)
            SetPixel hDCDest, Me.ScaleHeight - Y - 1, X, Col
        Next
    Next
   
    ' Remove form controls so they stop being painted
    Dim Control As Control
    For Each Control In Me
        Control.Visible = False
    Next Control
     
    ' Refresh form to call Form_Paint()
    Me.Refresh
End Sub

Private Sub Form_Paint()
    ' BitBlt the rotated form to the forms hDC
    BitBlt Me.hDC, 0, 0, Me.ScaleWidth, Me.ScaleHeight, hDCDest, 0, 0, vbSrcCopy
End Sub

Private Sub Form_Unload(Cancel As Integer)
    DeleteObject hBMPSour
    DeleteDC hDCSour
    DeleteObject hBMPDest
    DeleteDC hDCDest
End Sub
« Last Edit: September 23, 2006, 07:15:43 pm by headkaze »

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19428
  • Last login:Today at 01:14:11 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Can Johnny5 do rotated text?
« Reply #5 on: September 23, 2006, 07:17:16 pm »
I was just going to use the new freeimage dll I recently added to take a snapshot of the regular  layout, then rotate it with the included function twice (once for each player) and display them both in picture boxes on top of the actual layout. 

It means no animations, but seeing as how there isn't an easy way to rotate things speedily in gdi, it's a nice solution. 

loadman

  • Wiki Contributor
  • Trade Count: (+3)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4306
  • Last login:May 26, 2024, 05:14:32 am
  • Cocktail Cab owner and MaLa FE developer
    • MaLa
Re: Can Johnny5 do rotated text?
« Reply #6 on: September 23, 2006, 07:43:09 pm »
...specifically for dual control panels on cocktail tables?

Holy Crap!   Cocktails typically have simple control panels hence no need for a tool like J5.

What sort of Panel have you got that needs such a thing?

Howard_Casto

  • Idiot Police
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19428
  • Last login:Today at 01:14:11 am
  • Your Post's Soul is MINE!!! .......Again??
    • The Dragon King
Re: Can Johnny5 do rotated text?
« Reply #7 on: September 23, 2006, 10:53:10 pm »
...specifically for dual control panels on cocktail tables?

Holy Crap!   Cocktails typically have simple control panels hence no need for a tool like J5.

What sort of Panel have you got that needs such a thing?

Well that was kind of why it's so low on my list and I haven't bothered to implement it yet, I just wasn't going to say anything. 

Spartan

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 112
  • Last login:December 02, 2009, 07:09:38 pm
  • I like stuff!
    • The Municade
Re: Can Johnny5 do rotated text?
« Reply #8 on: September 24, 2006, 08:04:33 pm »
"Not yet" doesn't give you any clue?

Apparently not.

Quote
Holy Crap!   Cocktails typically have simple control panels hence no need for a tool like J5.

What sort of Panel have you got that needs such a thing?



It's a simple panel with 2 buttons on the left (think left/right for space invaders, an 8 way stick, and 3 buttons on the right) I was more interested in checking out its capabilties.  I had already modified (long ago) my MaLa theme to display the proper controls and to show which buttons do what, so I have the functionality already.