QB64 Phoenix Edition
_putimage (Solved) - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: _putimage (Solved) (/showthread.php?tid=4117)



_putimage (Solved) - Pete - 11-16-2025

Code: (Select All)
Palette 5, 63: Color 0, 5: Cls
t.mr = 40: t.ml = 10: t.InputRow = 10
MenuT = 7: MenuR = 30: MenuB = 15: MenuL = 18: mheight = 9: mwidth = 12
cp1 = 0
cp2 = 1

GoSub MakeInputField

Locate MenuT, MenuL
Color cp1, cp2
Print Chr$(218) + String$(mwidth - 2, 196) + Chr$(191)
For i = 1 To mheight - 2
    Color cp1, cp2: Locate , MenuL
    Print Chr$(179); Space$(mwidth - 2) + Chr$(179)
Next
Color cp1, cp2: Locate , MenuL
Print Chr$(192) + String$(mwidth - 2, 196) + Chr$(217);

Do
    _Limit 10
    _PutImage (t.ml * t.fw, t.InputRow * t.fh), lin2
    _Display
Loop Until Len(InKey$)
End

MakeInputField:
j = t.mr - t.ml + 2: t.fw = _FontWidth: t.fh = _FontHeight
CRed = 190: CGrn = 190: CBlu = 190
t1 = _NewImage((j + 1) * t.fw, 2 * t.fh, 32)
_Dest t1
Line (0, t.fh * 0)-(j * t.fw, t.fh * 1), _RGB32(190, 190, 190, 128), BF
Line (0, t.fh * 0)-(j * t.fw, t.fh * 1), _RGB32(0, 0, 0), B
lin2 = _CopyImage(t1, 33)
_FreeImage t1
_Dest 0
Return

The horizontal input field (rectangle) is a hardware image, which goes over the top of the blue box. What I want _putimage to do, in two statements, is eliminate the part going through the blue box. So the first _putimage statement would place the left portion of the input field from the same start position to the left margin of the blue box, and then a second _putimage statement would put the rest of the image from the right side of the box to the same finishing position. This would make it look like the blue box is over the input field.

Ah, I got it!

Code: (Select All)
Palette 5, 63: Color 0, 5: Cls
t.mr = 40: t.ml = 10: t.InputRow = 10: t.InputRow2 = 13
MenuT = 7: MenuR = 30: MenuB = 15: MenuL = 18: mheight = 9: mwidth = 12
cp1 = 0 ' Available menu item.
cp2 = 1 ' Popup background. (Same as mki.skin_bkg)
cp4 = 7 ' Shadow.

GoSub MakeInputField

Locate MenuT, MenuL
Color cp1, cp2
Print Chr$(218) + String$(mwidth - 2, 196) + Chr$(191)
For i = 1 To mheight - 2
    Color cp1, cp2: Locate , MenuL
    Print Chr$(179); Space$(mwidth - 2) + Chr$(179)
Next
Color cp1, cp2: Locate , MenuL
Print Chr$(192) + String$(mwidth - 2, 196) + Chr$(217);

Do
    _Limit 10
    _PutImage (t.ml * t.fw, t.InputRow * t.fh), lin2
    _PutImage (t.ml * t.fw, t.InputRow2 * t.fh), lin2, , (0, 0)-((((MenuL - 1) - t.ml)) * t.fw, t.fh)
    sx1 = (mwidth + MenuL - t.ml - 1) * t.fw: sx2 = (t.mr - t.ml + 2) * t.fw: sy1 = 0: sy2 = t.fh
    _PutImage ((MenuL + mwidth - 1) * t.fw, t.InputRow2 * t.fh), lin2, , (sx1, sy1)-(sx2, sy2)
    _Display
Loop Until Len(InKey$)
End

MakeInputField:
j = t.mr - t.ml + 2: t.fw = _FontWidth: t.fh = _FontHeight
CRed = 190: CGrn = 190: CBlu = 190
t1 = _NewImage((j + 1) * t.fw, 2 * t.fh, 32)
_Dest t1
Line (0, t.fh * 0)-(j * t.fw, t.fh * 1), _RGB32(190, 190, 190, 128), BF
Line (0, t.fh * 0)-(j * t.fw, t.fh * 1), _RGB32(0, 0, 0), B
lin2 = _CopyImage(t1, 33)
_FreeImage t1
_Dest 0
Return

And all it took was a big bowl of ice cream.

Pete