Author Topic: sprite editor  (Read 630 times)

Re: sprite editor
« Reply #15 on: July 04, 2018, 01:34:00 PM »
Thanks Petr, Fellippe and Steve!

Johnno needs to update image as drawn, already tested Petr's save, worked great!
« Last Edit: July 04, 2018, 01:35:32 PM by bplus »
B = B + ...
QB64 x 64 v1.2 2018 0228/86 git b30af92
QB64 v1.2 2018 0228/86 git b30af92
QB64 v1.1 2017 1106/82

Re: sprite editor
« Reply #16 on: July 04, 2018, 01:36:36 PM »
and thanks to Galleon!
B = B + ...
QB64 x 64 v1.2 2018 0228/86 git b30af92
QB64 v1.2 2018 0228/86 git b30af92
QB64 v1.1 2017 1106/82

Offline johnno56

  • Live long and prosper.
Re: sprite editor
« Reply #17 on: July 04, 2018, 05:21:52 PM »
Sorry. Cannot use 'saveimage'. All files placed with my program's directory. Placed the appropriate 'include' lines at the top and bottom. Before I can even execute the editor I get the error message, "DYNAMIC LIBRARY not found in line 2 of /home/john/Desktop/spriteditor/SaveImage.BI included on line 1"
The dll reffered to is 'zlib1'

I'm going to go out on a limb here and suggest that the saveimage library is for Windows only.... Just a guess.

J
Logic is the beginning of wisdom.

Offline FellippeHeitor

  • QB64 Developer
  • LET IT = BE
    • QB64.org
Re: sprite editor
« Reply #18 on: July 04, 2018, 05:32:02 PM »
It does use the dll that Steve provides in the package so yes, it's Windows only (and I failed to remember you're a Linux user, sorry about that).

If anyone using Windows would like to try the library, just make sure to fix SaveImage.BI file to make the declare library line reference the .dll file using a relative path by adding ".\" to the file name:

Code: [Select]
DECLARE DYNAMIC LIBRARY ".\zlib1"

Offline johnno56

  • Live long and prosper.
Re: sprite editor
« Reply #19 on: July 04, 2018, 06:00:24 PM »
What I need to know is, Does QB64 have the ability to pop up the OS's Save or Load GUI so as to either display all the previous files or give you the choice to enter a new filename. eg: Using MSPaint: If you select "File", from the top menu bar, a GUI panel pops up so that you can either 'Load' or 'Save' a file... That sort of thing...

Using variations of "get" and "put" still requires the user to "remember" the name of the file to load (or do a previous search for the filename)

This is exactly the same problem I had when I first started this editor using sdlbasic back in 2014. The upside is that I have learned some stuff about QB64 that I didn't know before... Cool.

Now. How about a nice game of Pong.... lol
Logic is the beginning of wisdom.

Offline FellippeHeitor

  • QB64 Developer
  • LET IT = BE
    • QB64.org
Re: sprite editor
« Reply #20 on: July 04, 2018, 06:21:20 PM »
If you were using Windows, you could just call the API and have the default dialogs show. For Linux, no easy deal.

Re: sprite editor
« Reply #21 on: July 04, 2018, 06:45:05 PM »
Hi Johnno56, it can be programmed. I would do this by creating a text file into which the program would store the last open file (a list of the last 20 open files and a path, that's not a problem), - if you mean doing this into a sprite editor. I can write it to you if you want to. I mean something similar to the IDE menu: File / Recent. It will only read a text file, and after the confirmation, the link you are pointing to will open.  In addition, I add a small sample of the sprite editor who does not do anything. :-D Use the arrows and the mouse wheel. This is the basis, tomorrow, if have time, if you want, I can add this Recent menu. Perhaps on the top edge, after mouse move to this area, what do you say?
Unfortunately, I can not help you with program for selecting files on a Linux disk if you mean this and you want to move around on the disk to select the file for editing. I have none knowledge in this - in Linux.

Code: [Select]
'sprite editor - base:
SCREEN _NEWIMAGE(800, 600, 32)
'first i load a picture and show it in grid:
REDIM D(0, 0) AS _UNSIGNED LONG
i& = _LOADIMAGE("bart.jpg", 32) '200 x 200 px image

grid = 5: W = _WIDTH(i&): H = _HEIGHT(i&)
PutToArray D(), i&: _FREEIMAGE i&

DO
    WHILE _MOUSEINPUT
        IF _MOUSEWHEEL THEN grid = grid + _MOUSEWHEEL: LINE (10, 10)-(500 + grid, 500 + grid), _RGB32(0, 0, 0), BF
    WEND
    IF grid > 25 THEN grid = 25
    IF grid < 3 THEN grid = 3
    CreateGrid D(), 10, 10, 500, 500, grid, a, b

    'keyboard for grid move (arrows)
    SELECT CASE _KEYHIT
        CASE 19200: a = a - 1 'left arrow
        CASE 19712: a = a + 1 'right arrow
        CASE 18432: b = b - 1 ' up arrow
        CASE 20480: b = b + 1 'down arrow
    END SELECT
    IF a < 0 THEN a = 0
    IF b < 0 THEN b = 0
    cellsX = (500 - 10) / grid
    cellsY = (500 - 10) / grid 'so is writed call for CreateGrid, for X is 1st and 3th parameter, for Y is 2nd and 4th parameter
    IF a > W - cellsX - 1 THEN a = W - cellsX - 1
    IF b > H - cellsY - 1 THEN b = H - cellsY - 1
    _DISPLAY
LOOP





SUB CreateGrid (D( x , y) AS LONG, PosXStart, PosYStart, PosXend, PosYend, ElementSize, a, b)

    xx = a: yy = b 'draw start array values


    FOR Y = PosYStart TO PosYend STEP ElementSize
        FOR X = PosXStart TO PosXend STEP ElementSize
            IF xx > UBOUND(D, 1) OR yy > UBOUND(d, 2) OR xx < LBOUND(d, 1) OR yy < LBOUND(d, 2) THEN EXIT SUB
            clr& = D(xx, yy)
            LINE (X, Y)-(X + ElementSize - 1, Y + ElementSize - 1), clr&, BF
            LINE (X, Y)-(X + ElementSize - 1, Y + ElementSize - 1), _RGB32(0, 0, 255), B
            xx = xx + 1
        NEXT X
        yy = yy + 1
        xx = a
    NEXT Y
END SUB


SUB PutToArray (arr() AS LONG, image&)
    W = _WIDTH(image&)
    H = _HEIGHT(image&)
    DIM m AS _MEM
    m = _MEMIMAGE(image&)
    REDIM arr(W, H) AS LONG
    FOR y& = 0 TO W - 1
        FOR h& = 0 TO H - 1
            _MEMGET m, m.OFFSET + 4 * ((W * y&) + h&), arr(x, y)
            PSET (x + 550, y + 50), arr(x, y)
            x = x + 1
        NEXT h&
        y = y + 1: x = 0
    NEXT y&
    _MEMFREE m
END SUB
Coding is relax (At least sometimes)

Offline johnno56

  • Live long and prosper.
Re: sprite editor
« Reply #22 on: July 04, 2018, 06:52:56 PM »
Fellippe,

I'm running with Linux... Even though I am using the Linux version of QB64, it usually always boils down to, 'It's a Linux/Windows thing'... Maybe, if I leave the editor 'on the shelf' for another 4 years, I may try again... lol

I need coffee...

Petr,

Thank you for the code sample and your advice... I am not using Windows...
This is the part were I duplicate the message to Fellippe... lol

I still need coffee...

J
Logic is the beginning of wisdom.

Re: sprite editor
« Reply #23 on: July 04, 2018, 07:01:58 PM »
For SaveImage I think Galleon's version should work, that Petr gave us.

As for getting files from current folder from which to select and load, also should be able to do in Linux.
But it would be easier if can clear screen to display list of files from which to pick and then be able to redisplay editor.

B = B + ...
QB64 x 64 v1.2 2018 0228/86 git b30af92
QB64 v1.2 2018 0228/86 git b30af92
QB64 v1.1 2017 1106/82

Re: sprite editor
« Reply #24 on: July 04, 2018, 07:04:09 PM »
Johnno56 - is there a command in Linux for list a disk into a text file, like in DOS DIR *. * > file.txt? If so, a primitive way to crawl the disk would go write. It should be the ls -l -R command but how to redirect it to a text file under linux, I do not know.
Coding is relax (At least sometimes)

Re: sprite editor
« Reply #25 on: July 04, 2018, 07:14:18 PM »
Quote
As for getting files from current folder from which to select and load, also should be able to do in Linux.
But it would be easier if can clear screen to display list of files from which to pick and then be able to redisplay editor.

This is exactly what I'm going to write if we find out how to list the contents of a linux disk into a text file. I've already done it under windows, so when we get a text file  under linux, that's just the different SHELL command.
Coding is relax (At least sometimes)

Re: sprite editor
« Reply #26 on: July 04, 2018, 07:21:10 PM »
Johnno56, try what do this: cat >files.txt  if it create files.txt file contains disk files list.
Coding is relax (At least sometimes)

Offline johnno56

  • Live long and prosper.
Re: sprite editor
« Reply #27 on: July 05, 2018, 12:17:14 AM »
Petr,

ls *.bas > files.txt works just fine and the list is sorted...

J
Logic is the beginning of wisdom.

Re: sprite editor
« Reply #28 on: July 05, 2018, 02:04:53 AM »
It does use the dll that Steve provides in the package so yes, it's Windows only (and I failed to remember you're a Linux user, sorry about that).

If anyone using Windows would like to try the library, just make sure to fix SaveImage.BI file to make the declare library line reference the .dll file using a relative path by adding ".\" to the file name:

Code: [Select]
DECLARE DYNAMIC LIBRARY ".\zlib1"

I'm thinking the library should still work for Linux users, as long as you point it to where zlib puts itself on your machine.

go to
System->Administration->Synaptic Package Manager
search for zlib1g-dev and install the package.

Of course, it's not going to find a *.dll file, but there should be a Linux equivelant to work off of.  QB64 SDL used to require ZLIB, and it worked on Linux, so somebody out there should be able to patch it all together to work.  (At least, I'd hope so.).

Offline johnno56

  • Live long and prosper.
Re: sprite editor
« Reply #29 on: July 05, 2018, 04:12:53 AM »
zlib1g-dev is already installed... Thanks for trying, Steve. Much appreciated.

J
Logic is the beginning of wisdom.