Posts: 2,177
Threads: 222
Joined: Apr 2022
Reputation:
104
What I'm shooting for is a way to get the hardware image UNDER the text. So far, even with the _DISPLAY order statement, no luck.
Code: (Select All)
Screen 0, 0, 0, 0
Width 80, 42
Palette 5, 63
Cls
_Delay .1
_ScreenMove 0, 0
_DisplayOrder _Software, _Hardware ' Reversing this order just eliminates the hardware image.
Overlay = _NewImage(_Width * _FontWidth, _Height * _FontHeight, 32)
x% = 7 * 16: y% = 3 * 8
_Dest Overlay
_Display
img& = _LoadImage("activate-static.png", 32)
_PutImage (x%, y%), img&
Overlay_Hardware = _CopyImage(Overlay, 33)
_PutImage (0, 0), Overlay_Hardware
_Dest 0
Color 0, 5
Locate 3, 10, 1, 7, 30
Print "sakf sfkj safjsf sfjsf";
_Display
Sleep
Right click image and "Save As" to your local QB64PE folder to test.
Pete
Posts: 2,697
Threads: 327
Joined: Apr 2022
Reputation:
217
Code: (Select All)
Screen 0, 0, 0, 0
Width 80, 42
Palette 5, 63
_PaletteColor 0, _RGBA32(0, 0, 0, 0)
Cls , 0
_Delay .1
_ScreenMove 0, 0
_DisplayOrder _Hardware , _Software ' Reversing this order just eliminates the hardware image.
Overlay = _NewImage(_Width * _FontWidth, _Height * _FontHeight, 32)
x% = 7 * 16: y% = 3 * 8
_Dest Overlay
_Display
img& = _LoadImage("z:\activate-static.png", 32)
_PutImage (x%, y%), img&, Overlay
Overlay_Hardware = _CopyImage(Overlay, 33)
_PutImage (0, 0), Overlay_Hardware
_Dest 0
'Color 0, 5
Color 5, 0
Locate 3, 10, 1, 7, 30
Print "sakf sfkj safjsf sfjsf";
_Display
Sleep
One major point of interest here:
SCREEN 0 has no alpha channel natively to any of the colors in it. The whole screen is FULL ALPHA BLACK (_RGBA(255, 0, 0, 0) for reference), so you can't print below that screen. Well, you can, but then you just immediately cover it up with black...
Think of it as painting a picture on your wall, and then painting the wall in black paint. You just completely cover and conceal the picture you painted.
You've got to set your overpaint to be a transparent clear coat. Paint your picture, then clear coat over it to preserve it.
NOTE in the above, I used _PALETTECOLOR to change BLACK to TRANSPARENT BLACK. Now you can lay the software screen over the hardware screen, and have no real issues.
Posts: 1,002
Threads: 50
Joined: May 2022
Reputation:
27
Well, that doesn't look particularly convincing either.
Posts: 2,177
Threads: 222
Joined: Apr 2022
Reputation:
104
In the meantime, I was going back in time, looking through some old notes and prior to PE, I dug up this, mildly modified...
Code: (Select All)
Screen 0 'just to highlight that this is going to be a scren 0 underlay
Color 0, 14
Cls , 14
For y = 1 To 50
Locate y, 1: Print "*"; String$(78, 32); "*";
Next
Locate 1, 1: Print String$(80, "*");
Locate 2, 40 - Len("Hello Pete! I'm a SCREEN 0 Underlay!") \ 2: Print "Hello Pete! I'm a SCREEN 0 Underlay!"
Color 4, 0: Locate 3, 1: Print String$(_Width * (_Height - 3), Chr$(3));
HW = _CopyImage(TextScreenToImage32(0), 33)
'Now that we've created our screen that we want to use as a hardware underlay,
'We now need to do at least a little tweaking to our normal screen 0 palette
_PaletteColor 1, 0 'set color 1 to become 0 alpha, 0 red, 0 blue, 0 green -- transparent black instead of solid black!
'note that 0 is still the same old solid black as usual.
Color 7, 1 ' white on transparent black
_DisplayOrder _Hardware , _Software 'draw the hardware screen under the software screen
toggle = Not toggle
Do
k = _KeyHit
If k = 32 Then toggle = Not toggle
Cls , 1 'clear the screen with a transparent black
If toggle Then _PutImage (0, 0), HW 'and now our
x = x - 1
If x < 2 Then x = 66
Locate 5, x: Print "HELLO SCROLL! ";
_Limit 10
_Display
Loop Until k = 27
Function TextScreenToImage32& (image&)
d& = _Dest: s& = _Source
Dim Plt(15) As Long
_Source image&
For i = 0 To 15: Plt(i) = _PaletteColor(i, image&): Next
f& = _Font(image&)
_Font f&
fw& = _FontWidth
fh& = _FontHeight
w& = _Width * _FontWidth
h& = _Height * _FontHeight '+ _HEIGHT
l& = (_Width * _Height) * 2 'The screen is width * height in pixels. (80X25) = 2000 X 2 bytes each = 4000 total bytes to hold a page of screen 0 text and color
tempscreen& = _NewImage(w&, h& + _Height, 32)
Screen0to32& = _NewImage(w&, h&, 32)
_Dest tempscreen&
Dim m As _MEM, b As _Unsigned _Byte, t As String * 1
Dim o As _Offset
m = _MemImage(image&)
o = m.OFFSET
_Font f&
For i = 0 To l& - 2 Step 2
_MemGet m, m.OFFSET + i, t
_MemGet m, m.OFFSET + i + 1, b
If b > 127 Then b = b - 128
fgc = b Mod 16: bgc = b \ 16
Color _RGB32(_Red(fgc, image&), _Green(fgc, image&), _Blue(fgc, image&)), _RGB32(_Red(bgc, image&), _Green(bgc, image&), _Blue(bgc, image&))
Print t;
Next
_PutImage , tempscreen&, Screen0to32&, (0, 0)-(w&, h&)
_FreeImage tempscreen&
_Dest d&: _Source s&
_MemFree m
TextScreenToImage32 = Screen0to32&
End Function
Did you code that for me for Valentines Day? Oh wait, I did admit to modifying it.. a bit. Maybe a couple of bits, but anyway. I'm glad to see your reply example is FREE of _MEM. I was hoping it would be less complicated, and it appears that is so. Nice!
Thanks Professor Steve!
Pete
Posts: 2,697
Threads: 327
Joined: Apr 2022
Reputation:
217
Posts: 2,177
Threads: 222
Joined: Apr 2022
Reputation:
104
03-08-2024, 01:30 AM
(This post was last modified: 03-08-2024, 01:31 AM by Pete.)
If it'z purdy youz wantz, it'z purdy youze getz!
Code: (Select All)
Screen 0, 0, 0, 0
Width 50, 30
Palette 5, 63
Palette 6, 56
_PaletteColor 0, _RGBA32(0, 0, 0, 0)
Cls
_Delay .1
_ScreenMove 0, 0
enl% = 5: Call font_size_setup(enl%)
_DisplayOrder _Hardware , _Software
_Display ' Turn autodisplay off.
Overlay = _NewImage(_Width * _FontWidth, _Height * _FontHeight, 32)
x% = 5 * 16: y% = 3 * 8
img& = _LoadImage("form.png", 32)
Do
_Limit 30
b$ = InKey$
If Len(b$) Then
Exit Do
End If
_Dest Overlay
_PutImage (x%, y%), img&
Overlay_Hardware = _CopyImage(Overlay, 33)
_PutImage (0, 0), Overlay_Hardware
_FreeImage Overlay_Hardware
_Dest 0
Color 6, 5
Locate 14, 16
Print "Yosemite Sam";
Locate 18, 16, 1, 7, 7
Print "sayyurprayersvarmint";
_Display
Loop
Color 0, 0: Cls
Sub font_size_setup (enl%)
If displayfullscreen% = -1 Then Exit Sub
WINXX1% = CsrLin: WINYY1% = Pos(1)
winmode$ = "2"
If enl% <> 0 Then
full = _FullScreen
If full = 0 Then
Select Case enl%
Case -1: If SCRNSIZE% > 0 Then Else Exit Sub
Case 1: If SCRNSIZE% < 14 Then Else Exit Sub
End Select
Else
Exit Sub
End If
End If
SCRNSIZE% = SCRNSIZE% + enl%
Select Case winmode$
Case "1"
full = _FullScreen
If full <> 0 Then _FullScreen _Off
GoSub ChangeFont
Case "2"
full = _FullScreen
If full <> 0 Then _FullScreen _Off
style$ = "MONOSPACE"
fontsize% = SCRNSIZE% + 13
If fontsize% < 14 Then winmode$ = ""
If fontsize% < 28 Then style$ = style$ + ", BOLD"
fontpath$ = Environ$("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path.
GoSub ChangeFont
Case "3"
GoSub ChangeFont
_FullScreen _SquarePixels
full = _FullScreen
If full = 0 Then GoSub nofull
Case "4"
GoSub ChangeFont
_FullScreen _Stretch
full = _FullScreen
If full = 0 Then GoSub nofull
End Select
Locate WINXX1%, WINYY1%
Exit Sub
nofull:
_FullScreen _Off
Return
ChangeFont:
If winmode$ <> "2" Then
_Font 16 ' Inbuilt 8x16 default font.
currentf& = _Font
Else
currentf& = _LoadFont(fontpath$, fontsize%, style$)
_Font currentf&
End If
If currentf& <> f& And f& <> defaultf& Then _FreeFont f&
f& = currentf&
Return
End Sub
One question. Now with the transparent black background needed, is there anyway to keep this effect with a different color background?
Pete
Posts: 2,697
Threads: 327
Joined: Apr 2022
Reputation:
217
Make the color background a hardware image itself. Just use SCREEN 0 for text text.
Posts: 2,177
Threads: 222
Joined: Apr 2022
Reputation:
104
I was afraid that would be the only option. Still, it's doable.
Thanks again for the help using the _PALETTE statement to get it working. I was just about to enter the 9th Circle of Hell before you posted. Hung an immediate U-turn and saw Clippy in my rear view mirror as I sped back to the forum.
Pete
|