| Welcome, Guest |
You have to register before you can post on our site.
|
| Forum Statistics |
» Members: 714
» Latest member: HenryG
» Forum threads: 3,569
» Forum posts: 31,908
Full Statistics
|
|
|
| _SaveImage less then 32BPP |
|
Posted by: mdijkens - 02-17-2026, 12:47 PM - Forum: Help Me!
- Replies (7)
|
 |
I've never ran into this, but it seems _SaveImage cannot save a PNG image with less then 32 bits per pixel?
I have a large image _NewImage(15000, 15000, 11) just black and white.
But saving it takes 22 seconds and is ~8MB
When externally converting to 1BPP PNG it is only 700KB
Is there a (fast) way to do this in Qb64pe ?
|
|
|
| _NEWIMAGE can't accept variables as dimensions? |
|
Posted by: bobalooie - 02-17-2026, 12:59 AM - Forum: Help Me!
- Replies (23)
|
 |
I am working on a project in which I would like to create images using _NEWIMAGE and calculated image dimensions. I have found that an 'Illegal Function Call' error is raised when I try to create an image like this:
DIM AS LONG Pict
DIM AS INTEGER iy
.
.
.
Pict =_NEWIMAGE(64, iy, 32)
Does _NEWIMAGE accept only numeric values for the dimensions? The wiki doesn't specifically say so but all of the examples use numeric dimension values.
TIA
|
|
|
| QBJS Sample fix(es) |
|
Posted by: bplus - 02-16-2026, 01:38 PM - Forum: QBJS, BAM, and Other BASICs
- Replies (5)
|
 |
@dbox going through samples (boy that link to tutorial was helpful!) I see an obvious quick fix to improve the Draw Contest Sample authored by yours truely.
quick fix for QBJS sample Draw Contest:
Code: (Select All) ' Mod MG DRAW by bplus 2023-10-08
'ref https://qb64.boards.net/thread/219/qb64-dev-competition-idea?page=2&scrollTo=1228
Dim i As Integer, ai As Integer, cc As Integer, u As Integer
Dim a$, s$
Randomize Timer
Screen _newimage(800, 600, 12)
Do
a$ = ""
Do Until Len(a$) > 20
If Random1(2) = 1 Then
If Random1(2) = 1 Then a$ = a$ + "L" Else a$ = a$ + "R"
Else
If Random1(2) = 1 Then a$ = a$ + "D" Else a$ = a$ + "U"
End If
a$ = a$ + Str$(Rand(1, 15))
Loop
s$ = a$
Cls
For i = 1 To 24
stepper = Val(Mid$(" 10 12 15 18 20 30 40 45 60 72 90120180", Int(Rnd * 13) + 1, 3))
For ai = 0 To 360 - stepper Step stepper
cc = Rand(64, 160)
If i > 10 Then u = 10 Else u = i
If i Mod 2 Then cc = 9 Else cc = 15
PreSet (400, 300)
'Draw "ta0" ' this needed?
a$ = "S" + Str$(22 - u * 2) + "TA" + Str$(ai) + "C" + Str$(cc) + s$
Draw a$
Next
Next
Print "spacebar for another, esc to quit"
Sleep
Loop Until Asc(InKey$) = 27
Function Rand& (fromval&, toval&)
Dim sg%, f&, t&
If fromval& = toval& Then
Rand& = fromval&
Exit Function
End If
f& = fromval&
t& = toval&
If (f& < 0) And (t& < 0) Then
sg% = -1
f& = f& * -1
t& = t& * -1
Else
sg% = 1
End If
If f& > t& Then Swap f&, t&
Rand& = Int(Rnd * (t& - f& + 1) + f&) * sg%
End Function
Function Random1& (maxvaluu&)
Dim sg%
sg% = Sgn(maxvaluu&)
If sg% = 0 Then
Random1& = 0
Else
If sg% = -1 Then maxvaluu& = maxvaluu& * -1
Random1& = Int(Rnd * maxvaluu& + 1) * sg%
End If
End Function
Gets it out of tiny screen 13 and centered in normal sized screen much more enjoyable to stretch drawing out.
Now I got to see why this isn't working in QB64pe but so much better in QBJS, I suspect screen new image needs 12 not 32.
Update again: yep that was it! Now fixed for both QB64pe and QBJS see code run below.
Update still again, helpful hint: note to quit run hit escape as instructed, that puts you back in forum, but if your screen is like mine you need to know you have to scroll up on forum page to see you are really escaped from QBJS.
|
|
|
| code locks up when SHELL |
|
Posted by: paulel - 02-15-2026, 06:36 PM - Forum: Help Me!
- Replies (4)
|
 |
i'm trying my programs on a different computer.
the programs frequently lock up when running the SHELL command, typically when executing "notpad.exe" or starting a .BAT file.
the other pc is running Windows 11 Home
they run just fine on my laptops, one runs Windows 11 the other 10.
any thoughts or suggestions?
|
|
|
| Valentine's Beating Heart |
|
Posted by: SMcNeill - 02-15-2026, 05:51 PM - Forum: Holiday Code
- Replies (31)
|
 |
Inspired by @bplus and his Valentine Heart, I had to make one as well.
My heart beats for you guys!
Code: (Select All)
Screen _NewImage(800, 600, 32)
_Title "Valentine Heart QB64PE"
Const TWO_PI = 6.283185307
Dim Shared Particles(1 To 300) As Particle
Type Particle
x As Single
y As Single
dx As Single
dy As Single
life As Single
col As _Unsigned Long
End Type
'-----------------------------------------
' Main loop
'-----------------------------------------
Dim t As Single, beat As Integer
Do
Cls , _RGB32(10, 10, 20)
t = t + .05
Dim scale As Single
scale = 8 + Sin(t) * 1.5
' Glow layers
DrawHeart 400, 300, scale * 1.25, _RGBA32(255, 0, 80, 40)
DrawHeart 400, 300, scale * 1.15, _RGBA32(255, 0, 120, 60)
DrawHeart 400, 300, scale, _RGB32(255, 0, 180)
' Beat detection
If Sin(t) > .95 And beat = 0 Then
Burst 400, 300
beat = 1
End If
If Sin(t) < .5 Then beat = 0
UpdateParticles
_Display
_Limit 60
Loop
'-----------------------------------------
' Draw a parametric heart at scale S
'-----------------------------------------
Sub DrawHeart (cx As Single, cy As Single, s As Single, col As _Unsigned Long)
Dim t As Single, x As Single, y As Single
For t = 0 To TWO_PI Step .01
x = 16 * Sin(t) ^ 3
y = -(13 * Cos(t) - 5 * Cos(2 * t) - 2 * Cos(3 * t) - Cos(4 * t))
PSet (cx + x * s, cy + y * s), col
Next
End Sub
'-----------------------------------------
' Spawn particle burst
'-----------------------------------------
Sub Burst (cx As Single, cy As Single)
Dim i As Integer
For i = 1 To 300
Particles(i).x = cx
Particles(i).y = cy
Dim a As Single
a = Rnd * TWO_PI
Particles(i).dx = Cos(a) * (Rnd * 4)
Particles(i).dy = Sin(a) * (Rnd * 4)
Particles(i).life = 1
Particles(i).col = _RGB32(255, 50 + Rnd * 150, 200)
Next
End Sub
'-----------------------------------------
' Update and draw particles
'-----------------------------------------
Sub UpdateParticles
Dim i As Integer
For i = 1 To 300
If Particles(i).life > 0 Then
Particles(i).x = Particles(i).x + Particles(i).dx
Particles(i).y = Particles(i).y + Particles(i).dy
Particles(i).life = Particles(i).life - .01
Dim a As Integer
a = 255 * Particles(i).life
Line (Particles(i).x, Particles(i).y)-Step(2, 2), _RGBA32(255, 100, 200, a), BF
End If
Next
End Sub
|
|
|
| Happy Valentine's Day! |
|
Posted by: bplus - 02-15-2026, 02:56 AM - Forum: Programs
- Replies (12)
|
 |
Inspired by Charlies BAM take on RR of BBC Conic Shape:
https://qb64phoenix.com/forum/showthread...3#pid39873
Code: (Select All)
_Title "Cardiac Conic Shape" 'b+ 2026-02-14
' inspired by CharlieJV BAM version of Richard Russle
' also inspired by today being Valentine's Day
Const xmax = 800, ymax = 600
Screen _NewImage(xmax, ymax, 32)
_ScreenMove 150, 50
Dim Shared blades: blades = 48
Dim Shared hX(1 To blades), hY(1 To blades)
Dim Shared OCX(1 To blades), OCY(1 To blades)
Dim pal~&(1 To blades)
For i = 1 To blades
pal~&(i) = _RGB32(255, (blades - i) / blades * 64 + 64, i / blades * 255)
Next
i = 0
' BIG outer circle map points from bottom of screen like heart is mapped
CX = xmax / 2
CY = ymax / 2
BigCircRadius = ymax / 2 - 10
'map the outer circle OCX, OCY points once and for all time!
For a = _Pi(.5) To _Pi(2.5) - .001 Step _Pi(2 / blades)
i = i + 1
OCX(i) = CX + BigCircRadius * Cos(a)
OCY(i) = CY + BigCircRadius * Sin(a)
Next
' heart
hCircRadius = .15 * BigCircRadius
a = -_Pi
While _KeyDown(27) = 0
Cls
' recalc heart points from new position
hOrigX = CX + hCircRadius * Cos(a)
hOrigY = CY + hCircRadius * Sin(a)
MapHeart hOrigX, hOrigY, 12
' draw line from center to heart point
For i = 1 To blades
Line (CX, CY)-(hX(i), hY(i))
' and line from heart point to outer circle
Line (hX(i), hY(i))-(OCX(i), OCY(i))
If (i Mod 2 = 0) Then
Color pal~&(i - 1)
Line (hX(i), hY(i))-(hX(i - 1), hY(i - 1))
Line (OCX(i), OCY(i))-(OCX(i - 1), OCY(i - 1))
End If
Next
_Display
_Limit 30
a = a + _Pi(1 / 45)
If a > _Pi Then a = -_Pi
Wend
'Reference and thanks to:
' http://mathworld.wolfram.com/HeartCurve.html
' find the 6th heart curve equations #7, 8
Function xCard (t)
xCard = 16 * Sin(t) ^ 3
End Function
Function yCard (t)
yCard = 13 * Cos(t) - 5 * Cos(2 * t) - 2 * Cos(3 * t) - Cos(4 * t)
End Function
Sub MapHeart (cx, cy, magnify)
' dim shared hX, hY 1 to blades
For a = -_Pi To _Pi - .001 Step _Pi(2 / blades)
i = i + 1
hX(i) = cx + magnify * xCard(a)
hY(i) = cy - magnify * yCard(a)
Next
End Sub
|
|
|
| _OpenFileDIalog$() and MouseButton(1) |
|
Posted by: Fantomas - 02-13-2026, 10:45 AM - Forum: Programs
- Replies (12)
|
 |
When i use _OpenFileDIalog$ to select a file to load, it seems that MouseButton(1) stay to -1 (without press left button) ?!
I need clic to make it change to 0.
How could i make MouseButton(1) = 0 because left button is not pressed ?
Thanks !
|
|
|
|