Page 1 of 2

Loading SCR to screen

Posted: Wed Sep 21, 2016 5:48 am
by swensont
I'd like to take an SCR file and load it onto a section of the screen. I plan on creating the SCR file by converting a JPG or PNG image to SCR (GD2). With a full size SCR, one would just LBYTES the file to the screen. I want to just have a small SCR file and load it into a window at a certain location (based in the pixel coordinate system). I'm looking for some sample code to do something like this.

Thanks,

Tim Swenson

Re: Loading SCR to screen

Posted: Wed Sep 21, 2016 9:45 am
by tofro
Tim,

you might want to have a look at Simon Goodwin's DIY toolkit, the "W" section (available from the usual place, in the Toolkits section). DIY TK has tons of useful features split into small toolkit sections that can be loaded and used seperately.

This has functions W_STORE and W_SHOW that allows you to copy S*BASIC window contents into memory and back (even colorplane-wise, if you use a limited set of colors, saving memory). There's an example S*BASIC listing included that shows how such windows stored to memory can be saved and restored to disk.

EDIT: Just seen that you need GD2 support - Above proposal will only work with standard QL screen modes.

For GD2, EasyPtr is your toolkit of choice, as we can safely assume you have the Pointer Environment. Steps here are as follows (note untested code):

Code: Select all

100 REM Save screen window of channel ch to file x$
110 DEFine PROCedure SaveWin (ch, x$)
102 LOCal addr
105 REM Create save area
120 addr = WSA_IN (ch)
125 REM You could be specifying coordinates here, default is to save whole of outline to memory area just created
130 WSASV #ch, addr
140 REM now save to file
150 S_WSA addr, x$
160 END DEFine
Loading works along the same lines, create a save area using WSA_IN, load to that area, then restore window from memory area
EasyPtr has a lot of options not used in the above (simplified) code, like only saving part windows, or only restoring part of the saved window.

Hope this helps
Tobias

Re: Loading SCR to screen

Posted: Wed Sep 21, 2016 4:29 pm
by dilwyn
One of my Quanta Helpline columns has some notes on programming graphics. Sadly, what you are asking is one of the easiest things to ask, the most difficult and lengthy to explain and program.

http://quanta.org.uk/wp-content/uploads ... INE-48.pdf

Re: Loading SCR to screen

Posted: Wed Sep 21, 2016 8:09 pm
by Giorgio Garabello
you can upload a picture in a EASYPTR menu, if the image is larger than the same menu or window?

Re: Loading SCR to screen

Posted: Wed Sep 21, 2016 8:16 pm
by tofro
Easyptr's load and save windows functions work independently from the menu extensions and based on window channel numbers. No need to have a menu loaded. And the save and load functions allow you to specify whatever subarea of the save window area to be moved to a window.

Tobias

Re: Loading SCR to screen

Posted: Wed Sep 21, 2016 8:23 pm
by Giorgio Garabello
OK, fine.
But I need to load an image in a specific area of an existing menu, the image is larger than the space available and would like to be able to scroll the image ...
But this is a different request from Tim, maybe I should open a separate topic.

Re: Loading SCR to screen

Posted: Wed Sep 21, 2016 8:31 pm
by tofro
Giorgio Garabello wrote:OK, fine.
But I need to load an image in a specific area of an existing menu, the image is larger than the space available and would like to be able to scroll the image ...
But this is a different request from Tim, maybe I should open a separate topic.
If what you are trying to load into the window is larger than the window, you need to cut what's too large and only copy what fits - when you scroll, you copy the screen parts that are "scrolling in" from the back buffer to the display window. Easyptr functions allow you to specify what part rectangles of the back buffer you want to copy.

Tobias

Re: Loading SCR to screen

Posted: Sat Sep 24, 2016 10:34 am
by Silvester
swensont wrote:I'd like to take an SCR file and load it onto a section of the screen. I plan on creating the SCR file by converting a JPG or PNG image to SCR (GD2). With a full size SCR, one would just LBYTES the file to the screen. I want to just have a small SCR file and load it into a window at a certain location (based in the pixel coordinate system). I'm looking for some sample code to do something like this.

Thanks,

Tim Swenson
Hot off the press...

As simple as FPIC_LOAD(ram1_image_pic)

Edit: File, see page 2 of this thread for latest version.

Re: Loading SCR to screen

Posted: Mon Sep 26, 2016 5:05 am
by swensont
Thanks Silvester, I'll have to give this a try. My first step was getting an JPEG image over to the QL. I created an image that was 200 pixels wide (and almost 200 high). I save it as .jpg and as .bmp.

I first tried BMP from Dilwyns site. That seems to lock up when I tried to do the convert. I got the "stop" symbol as a mouse. When I tried to kill the job, it was not listed.

I next tried the updated BMP (BMP102e). I basically got the same issue. I could view the picture just fine, but could not get it to convert to PIC.

I then tried the package PHGTK and tried the FJPEG() routine to convert the jpeg version to PIC. I kept getting "invalid syntax" when I tried that routine.

I have not tried the Windows programs that will convert from BMP to PIC because I'm using Linux. Granted I do have WINE installed, but I hoped the SMSQ/E based tools would work.

Tim Swenson

Re: Loading SCR to screen

Posted: Mon Sep 26, 2016 12:48 pm
by dilwyn
swensont wrote:Thanks Silvester, I'll have to give this a try. My first step was getting an JPEG image over to the QL. I created an image that was 200 pixels wide (and almost 200 high). I save it as .jpg and as .bmp.

I first tried BMP from Dilwyns site. That seems to lock up when I tried to do the convert. I got the "stop" symbol as a mouse. When I tried to kill the job, it was not listed.

I next tried the updated BMP (BMP102e). I basically got the same issue. I could view the picture just fine, but could not get it to convert to PIC.

I then tried the package PHGTK and tried the FJPEG() routine to convert the jpeg version to PIC. I kept getting "invalid syntax" when I tried that routine.

I have not tried the Windows programs that will convert from BMP to PIC because I'm using Linux. Granted I do have WINE installed, but I hoped the SMSQ/E based tools would work.

Tim Swenson
BMP was only ever intended to convert Windows files. The most recent version was updated by Bob Spelten jr - it might be worth liaising with him to seeif he is prepared to look at a sample file to see what the issue might be, for example if there are reversed order bytes in a non-Windows BMP.
Circumstances at the moment mean I won't get much time to do anything much on the QL in the near future.