Spectrum SCR editor

Share graphical tips, notes and queries related to our favourite screen layout and its editors.
Post Reply
User avatar
Vag
Drutt
Posts: 18
Joined: Sat Nov 12, 2022 4:52 pm
Location: Athens, Greece
Contact:

Spectrum SCR editor

Post by Vag »

Hello,
Back in 2005 I had translated Krakout in Greek. I remember I had searched for SCR editors and even though there were some, I wasn't completely satisfied with them (the same applies today). So, I started writing my own editor (for Windows). That program was incomplete but working. In any case, it is lost, only a screenshot exists:
Image

After many years, I translated two more Spectrum games (The Vectornauts and now Tiny nightmares). So, I decided to start over, but make it a really good program, that allows you to do many things, not just paint pixels. Due to the SCR format, certain things like rotation are really difficult, but everything will be done, at the end. I want it to have all functions of all existing SCR editors and much more.
It's not finished, it will take a lot of time till I release it. But I can tell you what I've done so far.

The window takes advantage of as much screen area as possible. You can zoom the image as much as your screen allows. The buttons and controls are rearranged automatically in smaller screen resolutions, so the program looks different depending on your desktop resolution.

The program can open SCR files, or TAP files (that have an SCR image).

You can show/hide different types of grid lines. Tile and pixel grid lines are the obvious options. Two vertical grid lines that distinguish the middle 24x24 square. Two horizontal grid lines that distinguish the three horizontal portions of the SCR. And of course, lines around the selected tile.
The tile editor has grid lines as well.

Two scratchpads for images and two scratchpads for tiles. You can switch the main image with the image of a scratchpad with a double click.

About the tile attributes:
You can select the colors or you can invert them, the flashing attribute and the bright attribute individually, or with a TrackBar. You can copy the attributes to the whole image. You can invert the attributes of the whole image. You can remove the attributes of the whole image. You can invert flashing of the whole image.

About the tile editor:
You can copy, paste, clear, invert, rotate, flip, mirror, move one pixel to four sides, and fill color. Also, you can select a character (letter) from many bitmap fonts. The Spectrum font and many others. As these are bitmap fonts, I have prepared some fonts that don't have letters, but gradients ;-)

About the image editor:
You can move the image to four sides one tile at a time. You can rotate the middle 24x24 square. You can flip and mirror it. You can enter letters and gradients from the bitmap fonts, line by line. You can also move the graphics pixel by pixel (but leave the attributes). You can copy, paste, clear, invert, invert flashing, remove attributes, remove graphics (and leave attributes). You can invert bright colors, or set bright colors to the whole image. You can zealous crop, and you can do it normally, or just horizontally or vertically. This cuts off the middle empty lines (see the last image). You can center the graphics, vertically, horizontally, or both.

About drawing:
You can draw with left or right click for the two colors.

The brush can be a pixel, 7 thicker squares, 6 thicker circles, two or three dots (vertical or horizontal). In total, there are 16 different point brushes.

You can draw with a paint spray or a paint gun and change the density.

You can draw lines. Normal lines and dotted, with a thickness of 1 to 8 pixels. Double doted line. Parallel lines, from 2 to 9 lines together. You can draw arrows. You can draw logarithmic and 8 different Archimedean spirals! You can draw perpendicular, triangle and square lines. You can draw the folium of Descartes. You can draw one, two or three quarters of a circle. Opposite circle quarters and curves (cubic Bezier, quadratic Bezier and Gauss line). Then, you can draw lines that are each of the above, but recurring. In total, there are 272 different line brushes.

You can draw ready made shapes. These are too many to mention. There are 128 buttons with shapes, but many of them have different shapes or variations. Simple ones like, circle, square, triangle, ellipse, egg, heart, 16 types of stars and more complicated ones, like the Yin Yang, the Sinclair logo, or three rotating sided rectangles, for example. Also, buttons that include bitmap graphics. E.g. the Space invaders sprites, Pacman sprites, Manic Miner sprites, spaceships, cars, bikes, helicopters, etc. These are hundreds, there are 240 cars for example. You can rotate all these at any angle.

You'll be able to draw patterns, repetitive shapes (I haven't done this yet).
E.g. dots, or lines or piano keys...

I will also implement some other functions for the image, like distortion. I haven't completed undo/redo, it's partly done. It will be able to show flashing, or display the usual loading routine. I also plan to implement selection of image portions, for copy, paste, or other functions, like mirroring, flipping, rotating. I would also like to make it multi-language. I know there are other image formats it could support, maybe in the future. I've seen another editor drawing and at the same time copying the same attributes, I may implement this as well (now it's drawing graphics and obviously doesn't change the attributes of the tiles). I may add fill color to the whole image, as well (you can do it per tile).

If you have any more ideas, please tell :-)
Here are some screenshots:

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image

Image
User avatar
g0blinish
Manic Miner
Posts: 287
Joined: Sun Jun 17, 2018 2:54 pm

Re: Spectrum SCR editor

Post by g0blinish »

Looking good. Any D/L link?
User avatar
Vag
Drutt
Posts: 18
Joined: Sat Nov 12, 2022 4:52 pm
Location: Athens, Greece
Contact:

Re: Spectrum SCR editor

Post by Vag »

Thanks!
No link yet as it's unfinished, sorry. I promise I'll try to make it worth the wait ;-)
I'm doing more projects at the same time, I'm translating some games and I'm also programing for work; but I'll try my best to finish it soon.
helpcomputer0
Microbot
Posts: 130
Joined: Fri Apr 22, 2022 6:11 pm
Contact:

Re: Spectrum SCR editor

Post by helpcomputer0 »

This looks great, lots of features!

I think there are many pixel art and graphic editors around, but one tool that doesn't really exist is advanced dithering techniques, particularly taking colour clash into account.

For example, if you have a shape that crosses different attributes in colour and/or brightness. If there were a gradiant fill tool that could automatically dither across different attributes automatically, that would be a huge leap forward since it can be one of the hardest and most time consuming tasks.

Another similar idea, is creating a shape across different attributes in colour and/or brightness where the shape (or just the outline) is automatically dithered to lesson the effect of colour clash and reduce the visible grid.

I'm not expecting you to implement these, but just some ideas.
firelord
Manic Miner
Posts: 557
Joined: Wed Nov 03, 2021 10:57 am
Location: Greece - Thessaloniki

Re: Spectrum SCR editor

Post by firelord »

Ωραίος...
Looks good. I had to do some SCR editing when I was making my CSSCGC submissions and I wasn't satisfied with the editors I found. I ended up doing some "tricks" . This editor seems better. If you release a 32bit version will probably work in linux using WINE.
User avatar
ParadigmShifter
Manic Miner
Posts: 671
Joined: Sat Sep 09, 2023 4:55 am

Re: Spectrum SCR editor

Post by ParadigmShifter »

Is a SCR file just raw data?

I too am looking for a loading screen editor. I tried ZXPaintbrush but I couldn't work out what the heckers to do there's so many buttons and no instructions.

I found one Youtube video about using it but the sound level was so low it was inaudible ha ha.

I was going to use The Artist (or Artist 2) lol... this looks much handier.

Anyway +1 for release it ASAP get people testing and using it, doesn't matter if it has features missing or bugs, I'm sure people will want to use it right away.

EDIT: Actually getting Undo working might be good first ;) Is it going to be multi-level Undo or just "undo last operation".

It's really worth building in Undo functionality as early as possible since it can be hard to retrofit (unless you just save the previous screen and push it onto a stack, that is easy). Much better to use the Command Design Pattern where each operation knows how to undo/redo itself.

If you not aware of that pattern (I always use it for Undo/Redo myself)

https://en.wikipedia.org/wiki/Command_pattern

You can either store a list of commands and re-execute them from the beginning up to the last operation (which is easy but slow) or else you can implement Command.Execute and Command.Undo which know how to perform its operation and how to reverse it (may need to store the data it overwrites as a rectangle for some operations in that case). Simple case is plot a pixel, Execute stashes the screen pixel coords and what value it had before, Undo reverts that.
User avatar
Vag
Drutt
Posts: 18
Joined: Sat Nov 12, 2022 4:52 pm
Location: Athens, Greece
Contact:

Re: Spectrum SCR editor

Post by Vag »

First of all, thank you all!
helpcomputer0 wrote: Sun Sep 10, 2023 7:19 pm one tool that doesn't really exist is advanced dithering techniques, particularly taking colour clash into account.
helpcomputer0 wrote: Sun Sep 10, 2023 7:19 pm Another similar idea, is creating a shape across different attributes in colour and/or brightness where the shape (or just the outline) is automatically dithered to lesson the effect of colour clash and reduce the visible grid.
Honestly, these sound too difficult... On the other hand, they are very interesting! You never know, maybe I could try...
firelord wrote: Sun Sep 10, 2023 7:49 pm If you release a 32bit version will probably work in linux using WINE.
I don't use Linux myself. to test it. Visual Studio has some options regarding the CPU, so we could test it together at some point, I think it won't be a problem (current setting is "Any CPU" so it should work).
In general, I don't use Windows system functions. I can see I have a reference to user32.dll, because I needed to check the Windows taskbar position and height. I don't know if that will prevent it from running on Wine, it shouldn't. I believe I could find a workaround, if that's the case, a secondary .exe that does this job (but is not necessary, so it will only run on Windows).
ParadigmShifter wrote: Sun Sep 10, 2023 8:04 pm Is a SCR file just raw data?
Yes.
here's a brief description, from a webpage:
These files are just Spectrum screen dumps, and are simply the 6912 bytes of pixel and attribute data found at address 16384, stored on disk in exactly the same way as they are stored in memory.

To elaborate; the Spectrum screen is split into four areas; top third, mid third, bottom third and attributes (colours). The thirds each consist of 2048 bytes and the attribute area is 768 bytes (32 characters wide x 24 lines). So the first 6144 bytes are the actual pixel data and the remainder decides what two colours are used in each 8x8 square.

Each third of the screen is laid out unusually; the first 32 bytes are the pixels for the top row of the first character line, then the next 32 bytes are the pixels for the top row of the second character line and so on until you reach the ninth load of 32 bytes, which is the second row of the first character line. Next 32 bytes is the second row of the second character line, and so on. It's hard to explain, so the best thing to do is see for yourself; write a program to POKE data to 16384 up and see how the bytes fill in on the screen.
ParadigmShifter wrote: Sun Sep 10, 2023 8:04 pmActually getting Undo working might be good first ;) Is it going to be multi-level Undo or just "undo last operation".

It's really worth building in Undo functionality as early as possible since it can be hard to retrofit (unless you just save the previous screen and push it onto a stack, that is easy). Much better to use the Command Design Pattern where each operation knows how to undo/redo itself.
Well, Undo/redo will be working perfectly when the program is released, it's one of the most needed and important things.
The SCR image and the equivalent Windows image that is displayed just have to be kept in memory, that's the easiest and fastest way. They need very small amounts of memory anyway, it can have hundreds of SCR states. Doing it the other way (use commands to undo) would mean executing functions and some need some time (e.g. rotation), whereas loading the previous image from memory is practically instant. There are things that will be happening, like checking which buttons should be enabled or disabled. If that makes it slow, I will have to keep their state in memory as well. It just gets complicated as I already have undo/redo for the tile editor and that would be affected by the image editor undo/redo.
It will be done :-)
AndyC
Dynamite Dan
Posts: 1409
Joined: Mon Nov 13, 2017 5:12 am

Re: Spectrum SCR editor

Post by AndyC »

Vag wrote: Sun Sep 10, 2023 9:09 pm
In general, I don't use Windows system functions. I can see I have a reference to user32.dll, because I needed to check the Windows taskbar position and height. I don't know if that will prevent it from running on Wine, it shouldn't. I believe I could find a workaround, if that's the case, a secondary .exe that does this job (but is not necessary, so it will only run on Windows).
Out of curiosity, why? It shouldn't ever be necessary to worry about the taskbar position. If you just maximize windows, setting their maximum size if necessary, Windows itself should take care of ensuring the taskbar is not blocked.
User avatar
Vag
Drutt
Posts: 18
Joined: Sat Nov 12, 2022 4:52 pm
Location: Athens, Greece
Contact:

Re: Spectrum SCR editor

Post by Vag »

AndyC wrote: Sun Sep 10, 2023 10:11 pm Out of curiosity, why? It shouldn't ever be necessary to worry about the taskbar position. If you just maximize windows, setting their maximum size if necessary, Windows itself should take care of ensuring the taskbar is not blocked.
You can't tell from the screenshots, but the image can't have any size. It could, I didn't want to - I wanted the zoom of the image to be an integer: 1x, 2x, 3x etc. (and not 1.5x, for example), so that the image always looks clear. This means the dimensions of the image on the window are multiples of 256x192 px. Because of this, if you could maximize the window, there would be a big space underneath and to the right of the image.
So, you can't change the size of the window and you can't maximize it. The maximum zoom size is determined by the screen resolution and the window size is determined by the maximum zoom. In fact, even if you change the screen resolution after you have opened the program, the window changes.

In these three screenshots, the screen resolution is different. First, notice that the buttons move to another area of the window. Also, notice that the height or width of the buttons as well as the empty space divider between buttons may be different! Sometimes the width has to be smaller, usually it's the height.
The first one is 800x600 px and the maximum zoom is 2x.
The second one has more space but the maximum zoom is still 2x. The buttons have to be arranged like with 800x600 px., but there's no need to be "condensed".
The third one is 1680x1050 px. Notice that the top of the image is above the bottom of the menu ;-) The program takes advantage of that little area as well. In that resolution, you can have 5x maximum zoom instead of 4x, just because of that :-)

I had to work for too many days, to perfect that! That was from the first things I did and that's why I forgot and I thought it was checking the Windows taskbar position and height - I just saw the code, it is checking the window border thickness! :lol:

Image

Image

Image
User avatar
ParadigmShifter
Manic Miner
Posts: 671
Joined: Sat Sep 09, 2023 4:55 am

Re: Spectrum SCR editor

Post by ParadigmShifter »

You can just use SetClientRect for that I think, no need to measure the border and the title bar (think it may take into account the menu bar as well)? May want to maximise (I think you can do that before WM_SHOW == ShowWindow), GetClientRect, do the calculation, then adjust though.

EDIT: Think it's AdjustWindowRectEx rather than SetClientRect. Presumably all other frameworks have a version of something like that anyway (I wouldn't write a Windows GUI app in anything other than C# these days).
Last edited by ParadigmShifter on Sun Sep 10, 2023 11:50 pm, edited 1 time in total.
C.Born
Manic Miner
Posts: 232
Joined: Sat Dec 09, 2017 4:09 pm

Re: Spectrum SCR editor

Post by C.Born »

If you double it all?
like for SCR0 and SCR1 ??
i need gigascreens for the viewer.
and with your application that could be hand drawn instead off the ingenious internet picture copy
velesoft uses layers off colours, very nice
https://zxart.ee/eng/software/demoscene ... simulator/
User avatar
Vag
Drutt
Posts: 18
Joined: Sat Nov 12, 2022 4:52 pm
Location: Athens, Greece
Contact:

Re: Spectrum SCR editor

Post by Vag »

ParadigmShifter wrote: Sun Sep 10, 2023 11:45 pmThink it's AdjustWindowRectEx rather than SetClientRect. Presumably all other frameworks have a version of something like that anyway (I wouldn't write a Windows GUI app in anything other than C# these days).
Well, I'm not touching anything that has to do with window and controls behavior, I finished all that some months ago and I'm totally happy :--)
By the way, border thickness is just GetSystemMetrics(SM_CXSIZEFRAME), if you declare function GetSystemMetrics from user32.dll. If that small detail prevents the program from running on Wine, I'll get rid of it
C.Born wrote: Sun Sep 10, 2023 11:50 pm If you double it all?
like for SCR0 and SCR1 ??
i need gigascreens for the viewer.
and with your application that could be hand drawn instead off the ingenious internet picture copy
velesoft uses layers off colours, very nice
https://zxart.ee/eng/software/demoscene ... simulator/
When I started thinking about the editor and programming it, I decided to deal only with the standard graphic mode. I was planning to make it a very comprehensive program anyway, I knew it would take many months to finish and that it would be hard to program. The standard graphic mode is used almost everywhere and all others are really rare. Some are not even used with the real Spectrum, they need emulators. This means that it would need too much effort for something very few people need. Don't get me wrong; ideally, the editor should support all known graphic modes, i would love that! Maybe in the future, after it has been released and updated some times, I may try to support some other graphic modes. Some of them are very similar to the standard one anyway, so it will be relatively easy. E.g. ULAplus is the same, except from the palette, and GigaScreen is like two rapidly alternating palettes (I think).

In my first message, I forgot to mention that it can move the image (the drawn shape) to the top, bottom, left, right, or center it :--)
Also, I said you can't maximize the window. You can't maximize it like all the other windows - if you click on the maximize button though, it will set the zoom to maximum, and the window will become bigger and (depending on the screen resolution) cover most of the screen.
C.Born
Manic Miner
Posts: 232
Joined: Sat Dec 09, 2017 4:09 pm

Re: Spectrum SCR editor

Post by C.Born »

off course, you have to have your aim
actualy i am "buzzy" with maybe 10 or 12 projects which move only a few byte per year.
eg i am looking on some simple C routines to split the BMP per coluor layer, i will see. just a few simple line to keep me going and maybe i get it working.
Post Reply