|
Post by rogcad on Jan 2, 2023 18:58:33 GMT
======================
knew-bee q:
I want to display an image file, then draw on top of that image using graphics commands such as "line" etc.
My program begins with:
SCREEN _NEWIMAGE(1280, 960, 13)
I then tried the following two methods:
'method 1: IF menuitem$ = "PI" THEN SCREEN _NEWIMAGE(1280, 960, 32) i = _LOADIMAGE("test32bit.bmp") _PUTIMAGE (0, 0), i END IF
Method "1" places the desired image file on the screen, but then my user-menu goes blank and the program will not receive any input. It's dead.
Also, with this method, if I allow the program to encounter:
Palette 0, 1315860
QB64 returns an error message of "illegal function call".
So I tried:
'method 2: IF menuitem$ = "PI" THEN SCREEN _NEWIMAGE(1280, 960, 32) i = _LOADIMAGE("test32bit.bmp") _PUTIMAGE (0, 0), i END IF
SCREEN _NEWIMAGE(1280, 960, 13)
That method (method 2) preserves the functionality of the program, but the image file I had displayed is gone.
------------------
Thanks in advance.
==============================
|
|
|
Post by bplus on Jan 2, 2023 22:52:52 GMT
Use image to fill screen stretch or shrink to fit
Screen _NewImage(800, 600, 32) ' screen width, height, 32 is _RGBA colors _Delay .2 Img& = _LoadImage("MyImageFile.png")
' fill entire screen with stretched out logo _PutImage , Img&, 0
' proceed to draw on screen = 0 above
' putimage in center of screen
Screen _NewImage(800, 600, 32) ' screen width, height, 32 is _RGBA colors _Delay .2 Img& = _LoadImage("MyImageFile.png")
' put image, the actual size, into the middle of our screen _PutImage ((_Width - .5 * _Width(Img&)) / 2, (_Height - .5 * _Height(Img&)) / 2), Img&, 0
_PutImage has tons of variations, this is 2 of the easier ones.
|
|
|
Post by rogcad on Jan 3, 2023 1:33:40 GMT
======================== Thanks bplus. Just noticed your response.
I'm not sure how to assign "screen = 0" to my drawing command.
My typical drawing command from QB45 is: LINE (GY(FP(LN)), GX(FP(LN)))-(GY(SP(LN)), GX(SP(LN)))
What does it need to look like in order to draw on screen = 0 or what additional code needs to preceed it?
Thanks in advance. This bit of advice will be all that I need to get my entire program where I need it to be. ========================
|
|
|
Post by bplus on Jan 3, 2023 4:42:40 GMT
EDIT: Screen 0 is default, 0 is the default handle number use for the main display screen used for _PutImage.
You can start drawing over your image as soon as you put it up with _PutImage. _Putimage can do all kinds of things with images for you blow up or shrink or 90 degree rotate sections of the source image onto the screen or another image container for building up images or saving them in different stages.
Create an image container \ drawing space with _NewImage(Width, Height, pallette) pallette = 32 gives you full color set, millions of colors for _RGB32()
_MapTriangle is another treasure, the first thing I started using it for is Filled Triangles, then for RotoZoom.
|
|
dualbrain
Junior Member
The only bug free code is code that is no longer used.
Posts: 51
|
Post by dualbrain on Jan 25, 2023 16:21:32 GMT
|
|
|
Post by bplus on Jan 25, 2023 19:10:46 GMT
I will give summary you can't do graphics (lines, circles, pset, ...) on Screen 0 or the default screen (no Screen N line), just text and x, y "points" are character cells in Locate Row, Column format. Mouse does work in screen 0 but again returns row and col not pixel x, y.
Screen N is old style kept for compatibility with past, you should learn to customize your screen with
Screen _NewImage(MyDesiredPixelWidth, MyDesiredPixelHeight, 32) ' the 32 gives you access to full _RGB32 colors including Alpha for transparency levels.
Screen 0 does have advantage of getting the character at a given "Locate" location, but I would use $Console:Only for all Text, so you can scroll your text.
|
|