Posts: 5
Threads: 2
Joined: Jan 2023
Reputation:
0
Can someone help me?
How to make. I will draw several different pictures in QB64.
I want to save these pictures to the computer's memory. Then I want to develop these images using _MapTriangle.
For example: Picture(1-100)
I don't want to record them from a file..
Const Xpix = 1920
Const Ypix = 1080
Screen _NewImage(Xpix, Ypix, 32)
_FullScreen
Dim As Long Pismeno(5)
Pismo& = _LoadFont("SANFW.ttf", 300, "monospace")
_Font Pismo&
Cx = 450: CY = 110
x = 100: y = 100
For t = 1 To 5
Pismeno(t) = _NewImage(x * 2, y * 2, 32)
_Dest Pismeno(t)
Locate 1, 1: Print t
Line (Cx - x, CY - y)-(Cx + x, CY + y), , B
'Get (Cx - x, CY - y)-(Cx + x, CY + y), Pismeno(t) - I keep getting this error
Cls
Next t
For t = 1 To 5
_Source Pismeno(t)
_Dest 0
_PutImage (Cx - x + c, CY - y), Pismeno(t)
c = c + 200
Next t
_Display
Posts: 3,985
Threads: 178
Joined: Apr 2022
Reputation:
222
01-28-2023, 06:54 PM
(This post was last modified: 01-28-2023, 09:48 PM by bplus.)
Well this sorta like what I think you want. Use _PutImage for both Get and Put
Think of _PutImage as copying an Image from one container to another. The screen is one kind of Container, another is made with _NewImage and another is a handle made from LoadImage. Maybe I should say, think of _PutImage as copying from one container handle to another. Main display screen has a handle = 0.
Code: (Select All) Const Xpix = 1290 ' you guys with the giant screen give me a break
Const Ypix = 700
Screen _NewImage(Xpix, Ypix, 32)
_FullScreen
Dim As Long Pismeno(5)
Pismo& = _LoadFont("Arial.ttf", 100, "monospace") ' don't have that other font 300 = 300 pixel high font
_Font Pismo&
Cx = 450: CY = 110
x = 100: y = 100
'For t = 1 To 5 ' one image first baby steps
Pismeno(1) = _NewImage(_PrintWidth("Hello World"), 100, 32)
Locate 1, 1: Print "Hello World"
Line (0, 0)-(_PrintWidth("Hello World"), 100), , B
'Get (Cx - x, CY - y)-(Cx + x, CY + y), Pismeno(t) - I keep getting this error
_PutImage , 0, Pismeno(1), (0, 0)-(_PrintWidth("Hello World"), 100)
Sleep 'check her out
Cls
'Next t
For t = 1 To 7
'_Source Pismeno(t)
'_Dest 0
_PutImage ((_Width - _PrintWidth("Hello World")) / 2, (t - 1) * 100), Pismeno(1), 0
'c = c + 200
Next t
_Display
Sleep
Don't forget to hit a key after you see first image of Print on Screen, that is image we are going to Get.
After key press we PUT the Image 7 times down middle of screen.
This is key:
_PrintWidth("Hello World")) ' tells me exactly how wide the box will be to fit the text, then we make _Newimage that size
Study _Putimage you can get and put both with it. Oh check out Keyword for day on _PUTIMAGE ;-)) I hear it's excellent LOL!
https://qb64phoenix.com/forum/showthread.php?tid=1119
Saving images to file is a completely different thing and I recomment SMcNeill's SaveImage routines/library.
Quote:I don't want to record them from a file..
Well then, never mind
PS: Welcome to the forum!
b = b + ...
Posts: 5
Threads: 2
Joined: Jan 2023
Reputation:
0
(01-28-2023, 06:23 PM)CSslymer Wrote: Môže mi niekto pomôcť?
Ako urobiť. Nakreslím niekoľko rôznych obrázkov v QB64.
Tieto obrázky chcem uložiť do pamäte počítača. Potom chcem tieto obrázky vyvolať pomocou _MapTriangle.
Napríklad: Obrázok(1-100)
Nechcem ich nahrávať zo súboru.
Const Xpix = 1920
Const Ypix = 1080
Obrazovka _NewImage(Xpix, Ypix, 32)
_FullScreen
Dim As Long Pismeno(5)
Pismo& = _LoadFont ("SANFW.ttf", 300, "monospace")
_Font Pismo&
Cx = 450: CY = 110
x = 100: y = 100
Pre t = 1 až 5
Pismeno(t) = _NewImage(x * 2, y * 2, 32)
_Dest Pismeno(t) Lokácia
1, 1: Tlač t
riadku (Cx - x, CY - y)-(Cx + x, CY + y), , B
'Získajte (Cx - x, CY - y)-(Cx + x, CY + y), Pismeno(t) – táto chyba sa mi stále zobrazuje
Cls
Next t
For t = 1 až 5
_Source Pismeno(t)
_Dest 0
_PutImage ( Cx - x + c, CY - y), Pismeno(t)
c = c + 200
Ďalší t
_Zobraziť
Posts: 5
Threads: 2
Joined: Jan 2023
Reputation:
0
Posts: 3,985
Threads: 178
Joined: Apr 2022
Reputation:
222
01-29-2023, 01:43 AM
(This post was last modified: 01-29-2023, 02:09 AM by bplus.)
That is QUITE a first program, we better step ours a up little
Code: (Select All) Const Xpix = 1300 ' you guys with the giant screen give me a break
Const Ypix = 700
Screen _NewImage(Xpix, Ypix, 32)
_ScreenMove 0, 0 ' my task bar in on right
_FullScreen
Dim As Long Pismeno(1 To 7)
Pismo& = _LoadFont("Arial.ttf", 75, "monospace") ' don't have that other font 300 = 300 pixel high font
_Font Pismo&
Cx = 450: CY = 110
x = 100: y = 100
For t = 1 To 7
Cls ' one image first baby steps
Pismeno(t) = _NewImage(_PrintWidth("1 Hello World"), 100, 32)
_PrintString (0, 16), _Trim$(Str$(t)) + " Hello World"
Line (0, 10)-(_PrintWidth("1 Hello World"), 90), , B
'Get (Cx - x, CY - y)-(Cx + x, CY + y), Pismeno(t) - I keep getting this error
_PutImage , 0, Pismeno(t), (0, 0)-(_PrintWidth("1 Hello World"), 100)
_Delay .1 'check her out
Next t
Cls
t = 1: d = 1
Do
Cls
'_Source Pismeno(t)
'_Dest 0
_PutImage ((_Width - _PrintWidth("1 Hello World")) / 2, (t - 1) * 100 + 5), Pismeno(t), 0
'c = c + 200
t = t + 1
If t = 8 Then t = 1
_Display
_Delay d
d = d - .02
If d <= 0 Then d = .1
Loop Until _KeyDown(27)
Cls
_PrintString ((_Width - _PrintWidth("Goodbye")) / 2, (_Height - 75) / 2), "Goodbye"
_Display '<<<<<<<<<<<<<<<<<<<<<<< very important once you start using _display you need to after every print thing!!!
Sleep
b = b + ...
Posts: 3,985
Threads: 178
Joined: Apr 2022
Reputation:
222
01-29-2023, 05:16 PM
(This post was last modified: 01-29-2023, 05:35 PM by bplus.)
OK next step towards "My First QB64 Program"
Test the new improved RotoZoom23r fixed up by James D Jarvis
'check her out
Code: (Select All) Option _Explicit
Const Xpix = 1300 ' you guys with the giant screen give me a break
Const Ypix = 700
Type box
As Single x, y, xsc, ysc, dxsc, dysc, a, da
As Long img
End Type
Screen _NewImage(Xpix, Ypix, 32)
_ScreenMove 0, 0 ' my task bar in on right
_FullScreen
Dim As Long Pismeno(1 To 7), Pismo, t, PW
Dim d ' as single
Pismo& = _LoadFont("Arial.ttf", 75, "monospace") ' don't have that other font 300 = 300 pixel high font
_Font Pismo&
PW = _PrintWidth("1 Hello World") + 20
For t = 1 To 7
Cls ' one image first baby steps
Pismeno(t) = _NewImage(PW, 100, 32)
_PrintString (10, 16), _Trim$(Str$(t)) + " Hello World"
Line (10, 10)-(PW - 10, 90), , B
_PutImage , 0, Pismeno(t), (0, 0)-(PW, 100)
'Sleep 'check her out
_Delay .1
Next t
Cls
t = 1: d = 1
Do
Cls , _RGB32(0, 100, 50)
_PutImage ((_Width - PW) / 2, (t - 1) * 100 + 5), Pismeno(t), 0
t = t + 1
If t = 8 Then t = 1
_Display
_Delay d
d = d - .05
Loop Until d <= .02 Or _KeyDown(27)
Dim bx(1 To 7) As box
Dim As Long i
For i = 1 To 7
bx(i).x = Rnd * (_Width - 100) + 50: bx(i).y = Rnd * (_Height - 100) + 50
bx(i).a = _Pi(2) * Rnd ' start twirl
bx(i).da = Rnd * _Pi(1 / 36) - _Pi(1 / 72) ' speed of twirl
bx(i).xsc = Rnd * 2.75 + .25
bx(i).ysc = Rnd * 2.75 + .25
If Rnd < .5 Then bx(i).dxsc = -.05 Else bx(i).dxsc = .05
If Rnd < .5 Then bx(i).dysc = -.05 Else bx(i).dysc = .05
Next
While _KeyDown(27) = 0
Cls , _RGB32(100, 100, 200)
For i = 1 To 7
RotoZoom23r bx(i).x, bx(i).y, Pismeno(i), bx(i).xsc, bx(i).ysc, bx(i).a
' update
bx(i).xsc = bx(i).xsc + bx(i).dxsc
If bx(i).xsc > 2 Then bx(i).xsc = 2: bx(i).dxsc = -bx(i).dxsc
If bx(i).xsc < -2 Then bx(i).xsc = -2: bx(i).dxsc = -bx(i).dxsc
bx(i).ysc = bx(i).ysc + bx(i).dysc
If bx(i).ysc > 2 Then bx(i).ysc = 2: bx(i).dysc = -bx(i).dysc
If bx(i).ysc < -2 Then bx(i).ysc = -2: bx(i).dysc = -bx(i).dysc
bx(i).a = bx(i).a + bx(i).da
Next
_Display
_Limit 20
Wend
Cls
_PrintString ((_Width - _PrintWidth("Goodbye")) / 2, (_Height - 75) / 2), "Goodbye"
_Display '<<<<<<<<<<<<<<<<<<<<<<< very important once you start using _display you need to after every print thing!!!
Sleep
' best rev 2023-01-20 Jarvis with Steve change for eff might need _Seamless next to _MapTriangle calls
Sub RotoZoom23r (centerX As Long, centerY As Long, Image As Long, xScale As Single, yScale As Single, radRotation As Single)
'uses radians
Dim As Long W, H, Wp, Hp, i, x2, y2
Dim sinr!, cosr!
Dim px(3) As Single: Dim py(3) As Single
W& = _Width(Image&): H& = _Height(Image&)
Wp& = W& / 2 * xScale
Hp& = H& / 2 * yScale
px(0) = -Wp&: py(0) = -Hp&: px(1) = -Wp&: py(1) = Hp&
px(2) = Wp&: py(2) = Hp&: px(3) = Wp&: py(3) = -Hp&
sinr! = Sin(-radRotation): cosr! = Cos(radRotation)
For i& = 0 To 3
' x2& = (px(i&) * cosr! + sinr! * py(i&)) * xScale + centerX: y2& = (py(i&) * cosr! - px(i&) * sinr!) * yScale + centerY
x2& = (px(i&) * cosr! + sinr! * py(i&)) + centerX: y2& = (py(i&) * cosr! - px(i&) * sinr!) + centerY
px(i&) = x2&: py(i&) = y2&
Next ' _Seamless? below
_MapTriangle (0, 0)-(0, H& - 1)-(W& - 1, H& - 1), Image& To(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
_MapTriangle (0, 0)-(W& - 1, 0)-(W& - 1, H& - 1), Image& To(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
End Sub
EDIT: a couple more improvements
b = b + ...
|