Author Topic: sprite editor  (Read 31265 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: sprite editor
« Reply #15 on: July 04, 2018, 12: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, 12:35:32 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: sprite editor
« Reply #16 on: July 04, 2018, 12:36:36 pm »
and thanks to Galleon!

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: sprite editor
« Reply #17 on: July 04, 2018, 04: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.

FellippeHeitor

  • Guest
Re: sprite editor
« Reply #18 on: July 04, 2018, 04: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: QB64: [Select]

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: sprite editor
« Reply #19 on: July 04, 2018, 05: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.

FellippeHeitor

  • Guest
Re: sprite editor
« Reply #20 on: July 04, 2018, 05: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.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: sprite editor
« Reply #21 on: July 04, 2018, 05: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: QB64: [Select]
  1. 'sprite editor - base:
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3. 'first i load a picture and show it in grid:
  4. i& = _LOADIMAGE("bart.jpg", 32) '200 x 200 px image
  5.  
  6. grid = 5: W = _WIDTH(i&): H = _HEIGHT(i&)
  7. PutToArray D(), i&: _FREEIMAGE i&
  8.  
  9.         IF _MOUSEWHEEL THEN grid = grid + _MOUSEWHEEL: LINE (10, 10)-(500 + grid, 500 + grid), _RGB32(0, 0, 0), BF
  10.     WEND
  11.     IF grid > 25 THEN grid = 25
  12.     IF grid < 3 THEN grid = 3
  13.     CreateGrid D(), 10, 10, 500, 500, grid, a, b
  14.  
  15.     'keyboard for grid move (arrows)
  16.         CASE 19200: a = a - 1 'left arrow
  17.         CASE 19712: a = a + 1 'right arrow
  18.         CASE 18432: b = b - 1 ' up arrow
  19.         CASE 20480: b = b + 1 'down arrow
  20.     END SELECT
  21.     IF a < 0 THEN a = 0
  22.     IF b < 0 THEN b = 0
  23.     cellsX = (500 - 10) / grid
  24.     cellsY = (500 - 10) / grid 'so is writed call for CreateGrid, for X is 1st and 3th parameter, for Y is 2nd and 4th parameter
  25.     IF a > W - cellsX - 1 THEN a = W - cellsX - 1
  26.     IF b > H - cellsY - 1 THEN b = H - cellsY - 1
  27.     _DISPLAY
  28.  
  29.  
  30.  
  31.  
  32.  
  33. SUB CreateGrid (D( x , y) AS LONG, PosXStart, PosYStart, PosXend, PosYend, ElementSize, a, b)
  34.  
  35.     xx = a: yy = b 'draw start array values
  36.  
  37.  
  38.     FOR Y = PosYStart TO PosYend STEP ElementSize
  39.         FOR X = PosXStart TO PosXend STEP ElementSize
  40.             IF xx > UBOUND(D, 1) OR yy > UBOUND(d, 2) OR xx < LBOUND(d, 1) OR yy < LBOUND(d, 2) THEN EXIT SUB
  41.             clr& = D(xx, yy)
  42.             LINE (X, Y)-(X + ElementSize - 1, Y + ElementSize - 1), clr&, BF
  43.             LINE (X, Y)-(X + ElementSize - 1, Y + ElementSize - 1), _RGB32(0, 0, 255), B
  44.             xx = xx + 1
  45.         NEXT X
  46.         yy = yy + 1
  47.         xx = a
  48.     NEXT Y
  49.  
  50.  
  51. SUB PutToArray (arr() AS LONG, image&)
  52.     W = _WIDTH(image&)
  53.     H = _HEIGHT(image&)
  54.     DIM m AS _MEM
  55.     m = _MEMIMAGE(image&)
  56.     REDIM arr(W, H) AS LONG
  57.     FOR y& = 0 TO W - 1
  58.         FOR h& = 0 TO H - 1
  59.             _MEMGET m, m.OFFSET + 4 * ((W * y&) + h&), arr(x, y)
  60.             PSET (x + 550, y + 50), arr(x, y)
  61.             x = x + 1
  62.         NEXT h&
  63.         y = y + 1: x = 0
  64.     NEXT y&
  65.     _MEMFREE m
  66.  
bart.jpg
* bart.jpg (Filesize: 7.24 KB, Dimensions: 200x200, Views: 353)

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: sprite editor
« Reply #22 on: July 04, 2018, 05: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.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: sprite editor
« Reply #23 on: July 04, 2018, 06: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.


Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: sprite editor
« Reply #24 on: July 04, 2018, 06: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.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: sprite editor
« Reply #25 on: July 04, 2018, 06: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.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: sprite editor
« Reply #26 on: July 04, 2018, 06:21:10 pm »
Johnno56, try what do this: cat >files.txt  if it create files.txt file contains disk files list.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: sprite editor
« Reply #27 on: July 04, 2018, 11:17:14 pm »
Petr,

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

J
Logic is the beginning of wisdom.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • Steve’s QB64 Archive Forum
Re: sprite editor
« Reply #28 on: July 05, 2018, 01: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: QB64: [Select]

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.).
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline johnno56

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

J
Logic is the beginning of wisdom.