Post Reply 
Keeping graphic objects in programs
12-27-2020, 11:43 PM
Post: #26
RE: Keeping graphic objects in programs
(12-27-2020 06:11 PM)cahlucas Wrote:  Dear Mr. Han,
But how can I call those .PNG files from my program? Of course these should be in the same directory as the program, but I don't know how to use them.

You will need to make use of the DIMGROB and BLIT commands. These commands also have a _P variation (i.e. DIMGROB_P and BLIT_P) that act on pixel-based screen coordinates. The non-"_P" versions use the current user's graphics settings. Generally speaking, prepare a graphics object (use the variables G1 through G9, as G0 is the current screen) using the DIMGROB command, and then "store" the PNG files into these graphics objects (use something like G1:=AFiles("mypicture.png"). Lastly, use the BLIT command to "draw" the graphics variable (G1 through G9) onto the screen (G0).

Quote:I also have another problem. In my application I use a square black cursor that, depending on the settings, must be projected over more or less square boxes in a grid, such that the character in it is visible in reverse video. The problem occurs when touching the screen on one of those boxes. The cursor must then immediately land on that box, and the content of that box can then be changed via the keyboard. Each box has an index number, and the difficulty now is to translate the mouse coordinates of the touch on the screen to the correct index number in the most efficient way possible. An additional problem is that the index numbers are not logically related to the boxes on the screen. This portion of the code will be critical to the correct operation of the program. And I don't have enough experience programming the Prime yet to implement this in the most efficient way. I hope I am not asking too much of you now, although I am confident that your knowledge and experience will be more than sufficient to overcome this problem. I am curious about your answer. Sincerely, Karel.

It may be useful from a programming perspective to create an ordered list of index values. The WAIT command can be used to trap your touchscreen coordinates (bottom of https://www.hpmuseum.org/forum/thread-216.html has a framework that you might find helpful). So for example, if you divide the 320x240 screen into a 10x10 array (each "block" is 32x24 pixels), then the list should be ordered so that the first 10 index values correspond to the first row of blocks, the next 10 index values correspond to the second row, etc. The (x,y) coordinates from the touchscreen can be obtained from the WAIT command, and it should be a simple matter of integer division. Suppose your list is called IndexList. If n = floor(x/32)*10 + floor(y/24), then IndexList(n) should get you the desired index.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Keeping graphic objects in programs - Han - 12-27-2020 11:43 PM



User(s) browsing this thread: 1 Guest(s)