Translucency, video editing and mosaic work in PaintCAD 4Windows 1.2.1

  • Tutorial
Each of us at least once in my life wants to create a picture with translucency, assemble an animation from simple drawn frames, tear out some kind of frame from an AVI movie and create a mosaic map, subsequently writing a two-dimensional game in which the hero runs around this loaded map.

Oddly enough, but in the free paint editor PaintCAD 4Windows from version 1.2.1 it became possible:
  • create / load pictures with a translucent background from PNG files and save them in PNG
  • it’s convenient to edit the sequence of BMP / JPG frames in the special interface “Frame Queue”, apply various effects to them and collect AVI video files from them
  • disassemble existing AVIs into frames, extract frames from them individually or immediately in a certain range
  • create mosaic cards for games or design tables, drawing mosaic elements (tiles) individually or surrounded by neighboring elements, check the joints between them, create layouts from tiles, save and load layouts



How to do all this? And how was it developed?



Using the alpha channel in PaintCAD 4Windows


It so happened that the paint path has no layers. Here the picture is a “piece of paper” with a picture. Therefore, the question "what is behind the picture?" Never stood. Behind the picture there is a background color (it is the background color, it is also ZTs). All operations for cutting or shifting pixels knew what should be left in the empty spaces of the ZC.


When the still ancient Java-based mobile version of the paint path was being developed back in the 200s, then in addition to the Insert , which inserted the copied rectangular fragment, a Special Insert appeared . It was necessary to insert one picture on another, at the same time indicate the transparent color path, which was not inserted on the picture. This all later moved to the Windows paint path:


Transparent color was eliminated, the object was inserted, everyone was happy.


And to make them even happier, you could indicate with what percentage of transparency to insert the remaining opaque piece of the picture:


But after all these operations, the background of the picture still remained opaque.

In version 1.2.1, the PNG format was added to the command to open any file types known to the path (Ctrl + O, "??? - file") . And if the paintcade feels that there is an alpha transparency channel inside the file, then it will ask you:


To load both the picture and the alpha channel, you need to select the third item “Picture to picture, alpha to clipboard” .

Then here is a picture on a transparent background:


the image channel (which will be shown in the picture) and the alpha channel (which will be in the internal buffer of the paint path), on which white pixels are completely opaque, black pixels are completely transparent, gray pixels are intermediate gradations of transparency will be decomposed in the paint path:


And if then when saving to indicate that we want to save “PNG”, then the printcade will ask you again about transparency:


And when you select “Use buffer as alpha channel”, it will save PNG back along with its alpha channel.

Accordingly, to create a picture with translucency from scratch, you need to copy your picture to the buffer (Ctrl + C) and bring it there in the buffer to the alpha channel condition . Therefore, it was necessary to quickly switch between the buffer and the pattern.

Previously, such commands were already added to the paintcade, this is “Figure <-> Buffer” in the command menu by Ctrl + Right, and this is an exchange of a picture and a buffer in 3D stereo drawing mode. But here it was necessary to duplicate this command again, to make it accessible, easily launched from the keyboard at any time, and to make it clear that it was “to switch between the picture and the alpha channel”.

Therefore, in the main menu (which turns on when you click on the "Menu" button in the upper left corner of the window or by pressing "0" on the keyboard), a whole new submenu "Alpha" was added . The first command "Figure <-> Buffer" appeared in it ( Ctrl + D) and now, using this keyboard shortcut, you can switch between the picture and its alpha channel.


In the process of drawing, I want to see "how will my drawing look on a transparent background." Therefore, in the Preview (F3) , the button "Alpha Overlay (D)" was added , available for pressing when the buffer is not empty.


By clicking on this button or the “D” key, you can preview not only a picture, but a picture superimposed with alpha on a black background, white background or mesh background (which clearly shows how transparency is laid out over a regular texture).

Also, the user may want to apply this picture with alpha to a certain background - for this, in the "Alpha" menu there is a second command "Paste alpha from the buffer to the picture", which will offer you options in which, in addition to the Black, White and Mesh backgrounds, there will be PC and ZC color backgrounds:


But this overlay option is rarely used, more often the user may want to take such PNG with an alpha channel, load it and then overlay it on some other picture.

Because There is only one picture and one buffer in the paint path, then if our PNG and its alpha channel are stored in them, then where to put the picture on which we want to insert this whole thing?

To do this, the Alpha menu contains the last two commands.

“Capturing a picture and alpha buffer for a special insert” (Ctrl + Shift + C)- puts the alpha channel in a special slot. After that, the picture is copied to the buffer. And now the inserted picture is in the buffer, its alpha channel is in the special slot. The current drawing is empty. We open the picture on which we will insert. And we use the Special Insert (in the Selection and clipboard menu, accessible by Alt + ".") - after Capture, she knows that she doesn’t need to ask anything about transparency, she just needs to use the alpha channel from the special slot.

Thus, we put our PNG with an alpha channel on any other picture:


As soon as we finished inserting a picture with an alpha channel, we need to cancel the capture so that the Special Paste works again as usual, for this we call the “Cancel Capture” command in the Alpha menu (Ctrl + Shift + X) .

Thus, in PaintCAD 4Windows, you can draw pictures with translucency, load them from PNG, save them in PNG and paste them into other pictures.

Video editing in PaintCAD 4Windows


Previously, in the mobile version of the paintcade, a packer of animated GIFs was written. And therefore, the concept of “Video” did not exist in the paint path, there was only GIF animation. It was possible to collect animations from GIF frames and parse them into GIF frames.

All this work with GIFs was also transferred to the Windows paint path and was always in the Utilities menu:


Animated GIFs have a feature: each frame can have any delay. There is no concept of “FPS” or “Number of frames per second”:

(in the paintcade frames for videos and animations are stored in separate files, for example, 1000 GIF frames are in the folder - and you can collect one GIF animation from them)

When copying the paintcade under windows The ability to build AVI video files from BMP / JPG frames was added. And here the problem was identified -you can’t just take and hold one of the frames of an AVI file .

In addition, frames are simply named 1.bmp, 2.bmp, 3.bmp .... 9.bmp, 10.bmp ... 99.bmp, 100.bmp, etc. in the path, and so, for example , delay the third frame in AVI for a second at a playback speed of 24 frames per second - you need to duplicate it from 3.bmp to 26.bmp, and for all the frames that were ahead - increase the names in the file names by 24.

Therefore, I really needed a tool video editing to handle long sequences of frames. And in version 1.2.1 it appeared.

And because of it, even a whole structured menu of “Utilities” appeared - “Processing BMP / JPG frames” .


The first item in this menu is “View Queue (Ctrl + J)”- And there is a utility call for video editing. After calling this item and selecting one of the BMP / JPG file-frames of your sequence, a window for viewing and editing the sequence of frames appears:


From left to right at the bottom of the window is the queue itself. On each frame is written his name and the time of his show. If you hold Shift , instead of time, a mini-image will be displayed on each frame.

At the top left of the window, a frame image is displayed scaled to the size of this preview area.

Information is displayed at the top right of the window: the file name of the frame, the frame size in pixels, the current playback speed in frames per second, the length of the current selection (start-end of the selection), a segment of the sequence of frames copied to the buffer.

The user can easily run in frame succession with the cursor (just run in 1 frame, holding Q - 10 frames, A - 100 frames, Z - 1000 frames, W - 10,000 frames per step), select part of the frame queue, copy or move it, take a freeze frame (tighten one frame), insert an empty space (by moving the remaining frames in front) and much more (for more details, see below the purpose of the buttons) . At the end, after editing the sequence, you can play the selected section and the entire sequence. And then collect it in AVI and run it on the default player for playing AVI on your system.

Button assignment in the video editing window
F2 - stretches the window to full screen to make it better visible.

K / S (F) - brings up a window for setting the number of frames per second for future animation (from 1 to 30 fps).

Previous (LEFT) and Next (RIGHT) - moves the cursor through the frames of the sequence.

Go (G) - brings up the menu for choosing the place of transitions. You can go backward or forward to the nearest break in the sequence, backward or forward, or to a specific frame until the end of the animation (then you need to enter the frame number).

Edit (ENTER) - opens the frame on which the cursor stands, in the path through "Open ???".

Highlight (SPACEBAR)- starts / ends to highlight a segment of the sequence. If you apply twice on the same frame, the selection is reset and it is considered that it is in the current cursor position and 1 frame long (moves with the cursor).

Copy (Ctrl + C) - remembers the selected segment of the sequence

Paste (Ctrl + V) - transfers a copy of the sequence segment previously copied by the Copy (Ctrl + C) function to a new location, the first frame of the segment is placed where the cursor is.

Move (Ctrl + B)- transfers a copy of a segment of a sequence previously copied by the Copy (Ctrl + C) function to a new location, the first frame of the segment is put where the cursor is. The old location of the segment is cleared of frames (i.e. frames are transferred to a new location).

Delete (Ctrl + X) - the selected segment of the sequence is cleared of frames after the user confirms the operation.

Play (P) - starts playing a sequence of frames with the “K / C (F)” button set. If a segment of a sequence is selected, then there is an endless looping playback of this segment.

Download Queue (L)- launches a file open dialog for selecting an editable sequence. In this way, you can switch to editing a different sequence of frames in another folder.

Effects (E) - brings up the effects selection menu for the selected frame segment. The following effects are available:
  • Shift / copy - shift or copy the selected sequence of frames.
  • Freeze frame - if one frame is selected, it requests the length of the freeze frame and stretches this frame to the selected length (erasing everything that gets in its way), and if a segment of a sequence is selected, it smears the first frame of the selected segment throughout the sequence.
  • Multi-shot frame - spreads each N-th frame in the rest (N-1) frames ahead of itself, the output is a “slow-down" video, in which frames rarely change.
  • Reverse - reverses the location of the frames of the selected segment to the opposite (the first frame of the selection will be the last).
  • Repeat - repeats the selected segment of the sequence the selected number of times.
  • Random mix - randomly mixes frames in the selected segment of the sequence.
  • Speed ​​up / slow down - stretches / compresses the selected segment of the sequence to the specified length (in frames).
  • Insert blank space - inserts the selected number of blank frames at the current cursor position, shifting the entire part of the animation in front.


Make AVI (R) - calls the assembly of AVI video from a sequence of frames. For a successful assembly, you must have at least the first frame (1.bmp / ​​1.jpg).

Show AVI (S) - opens the last collected AVI in your video player (installed in the system by default for playing AVI files).

Exit (ESC) - closes the window for viewing the frame queue. The next time the window is called up, it will immediately open showing the frame queue selected the previous time. To change the frame queue to another, use the Load Queue button (L).

The rest of the menu items “Processing BMP / JPG frames” are intended for additional tasks, such as converting GIF frames to BMP / JPG frames and vice versa, performing batch processing of frames with effects of the type Brightness, Contrast, multiple image magnifier Expander (with the possibility of using different algorithms such as advMame2x , advMame3x, simple increase, etc.), Cropping frames, Resizing frames, Renaming third-party frames in 1.bmp, 2.bmp format and vice versa.

Functions of menu items Processing BMP / JPG frames
Batch processing - applies to all frames (from the first frame 1.bmp / ​​jpg to the nearest gap or the end of the sequence, if there is nothing behind the gap) of the selected sequence one of the effects:
  • 1. Color, Contrast, Brightness, Color, Gamma - parameters are selected by the user and apply to all frames;
  • 2. Expander - any of the options for this effect of increasing the image size in all frames;
  • 3. Fragment - cuts off all frames of the sequence according to the current selection. To apply this processing, first open one of the frames and select its necessary fragment, and only then call the processing;
  • 4. Raster size - scales all frames to the size selected by the user.


Conversion - turns BMP / JPG frames into 256-color GIFs according to the selected method (simple and accurate UNI-palette, hyper-palette), and vice versa.

Frame queue - shift / copy frames and a freeze frame with application boundaries in the form of numbers (in the Queue Viewer window - completely the same, but there the boundaries are indicated visually using the selection and cursor position).

Third-party frames - rename frame files to Paintcad format and vice versa:
  • “Rename to N.xxx” - rename frames with the names image001.jpg, image002.jpg or DSC_0053.jpg, DSC_0054.jpg to the usual format for the image path 1.jpg, 2.jpg. In this case, rename.rnl is created in the folder with frames, into which old and new file names are written.
  • “Rename names by RNL list” - using the rename.rnl file created earlier, the frame files are renamed back to their old names.



Video editing: AVI parsing into frames


The same video editing interface, but with reduced capabilities (because frames cannot be moved in avi as easily as frames can be moved on the hard drive), is shown to the user by calling “Parse AVI video to BMP / JPG frames” :


Then, the frame queue is displayed simply frame numbers (not files), you can also navigate through them, play them, import a specific frame into the image path, merge the selected frame range onto the hard disk. At the same time, the information panel shows the total number of frames in the AVI file, the speed (FPS) of the open clip, and the frame size in the video.


On average, a normal one and a half (two) hour film at 24 frames per second is about 130-170 thousand frames. Therefore, moving along it (for example, holding the above W- 10 thousand frames per step) is quite easy.

Thus, you can pull out the necessary frames from AVI, then use the menu “Processing BMP / JPG frames” to crop them, make them the right size, turn them into GIFs and do them,
e.g. animated avatar:



Mosaic Editor in PaintCAD 4Windows


There is another interesting menu in the Utilities menu - “Mosaic Editor” :


The first item in this menu is “View Mosaic (Ctrl + Y)” , it asks for one of the mosaic element files (described below) and then displays a window Editor’s


Note : A mosaic is a set of two-dimensional square or rectangular elements (tiles) of the same size (“tile set”), which can be connected to each other into a single image, thus drawing, for example, a map for playing with roads, rivers and lakes, forests and seas, sands and lava. You can also draw beautiful borders for tables, which are then used on web pages.

Drawing tiles as separate pictures is difficult, because you need to keep in mind in what place the elements of the tiles are connected to form a single picture. This helps the mosaic editor.

Preparing to draw a mosaic
1a. If the mosaic is created from scratch: create a new picture in the paint path the size of a single mosaic element, save it under the name "1.bmp" in an empty folder.

1b. If you already have ready BMP mosaic elements with scary names, then rename them to the paintcade format (1.bmp, 2.bmp, 3.bmp) with the “Utilities” command - “Processing BMP / JPG frames” - “Third-party frames” - “Rename in N.xxx. "

1c. If there are already ready BMP mosaic elements with normal names like 1.bmp, 2.bmp, 3.bmp, then just go to step 2.

2. Call in the main menu “Utilities” - “Mosaic Editor” - “View Mosaic” ( or press Ctrl + Y). When the dialog box for opening a file appears, select the mosaic element file “1.bmp”.

3. A mosaic editor window will appear on the screen.

In the mosaic editor, a matrix of 3x3 elements is created by default; you can change the size of the matrix. The user moves the cursor within the matrix and sets with the keys (Z, X) the number of elements in each cell of the selected matrix fragment, or, using the Effects (E) menu , fills the matrix region with a specific element number, copies and pastes the matrix fragments to different places, such by creating a layout of elements. After that, you can save the layout (so that tomorrow they will not be arranged again while continuing to draw the mosaic, but simply load it into the editor). You can edit each mosaic element individually or surrounded by other elements in order to qualitatively draw joints with them (and then save this element separately, see below for more details)“Assignment of buttons in the mosaic editor window” - “Import matrix (CTRL + ENTER)” ). After saving the corrected element, we return to the mosaic editor and once again check that everything is fine with it. And so on with all the elements.

Button assignment in the mosaic editor window
Left, Right, Up, Down - moves the cursor on the matrix, allowing you to select the cell to be selected

Selection (SPACE) - starts / stops highlighting a two-dimensional fragment of the matrix. If you double-click on one element, then the selection is reset and subsequently follows the cursor. The current selection borders and cursor coordinates are shown at the top left of the window.

Previous (Z), Next (X) - increases / decreases the number of the mosaic element in all cells of the current selection. The item number corresponds to the file name.

Details (D) - show / remove item numbers and cursor. So that you can better consider the joints of the elements of the resulting mosaic.

Matrix (M) - set the dimensions of the matrix horizontally and vertically.

Effects (E) - brings up the effects selection menu for the selected two-dimensional fragment of the matrix. The following effects are available:
  • 1. Fill selection with number - sets the selected element number in all cells within the selection.
  • 2. Copy selection - copies the selected fragment of the matrix into memory.
  • 3. Paste - pastes the previously copied fragment, starting from the current cursor position (there will be the upper left corner of the fragment).
  • 4. Invert the selection horizontally - changes the arrangement of the elements of the selected two-dimensional fragment to the opposite horizontally.
  • 5. Invert the selection vertically - changes the arrangement of the elements of the selected two-dimensional fragment to the opposite vertically.
  • 6. Fill the selection with increasing numbers - sets successively increasing numbers of elements within the selected fragment. Thus, on a large map, you can fill in a line with two or more elements from the edge to make it easier to select them when creating a map.


Load Elements (L) - allows you to load other elements from another folder into the mosaic editor.

Load layout (O) - allows you to load a TLO file with a previously saved matrix with the arrangement of elements into the mosaic editor.

Save Layout (S) - allows you to save the current matrix with the arrangement of elements in a TLO file. File TLO format: text, line by line: matrix width, matrix height, then successively in horizontal rows, the number of elements in the matrix, one per line of the file. You can open it in notepad and edit it manually.

Editing an item (ENTER)- Opens in the pathcade the element located in the cell under the cursor through "Open ???". If the element file does not exist, then the paint cad will create an empty file the size of the 1.bmp element, and will remember the name of the element in the matrix for future storage in BMP.

Import Matrix (CTRL + ENTER)- imports the image of the entire matrix with elements into the paint path. In this case, the element on which the cursor was located is within the selection. And the file name of this element is already assigned to the save dialog. Therefore, after editing and docking the edges of this element with others in the matrix, it is recommended to call the Fragment function in the command menu (Ctrl + Right), chopping off everything outside the selected element and saving it back to its BMP file by pressing Ctrl + S (the file name will already be entered into the save dialog). After that, you can return to the mosaic editor (Ctrl + Y) and see how the edited element lies among others in the mosaic.

Output (ESC)- closes the mosaic editor window. The next time the window is called up, it will immediately open showing the layout installed last time and the elements loaded last time. To change items to others from another folder, use the Download items button (L).


Restore the mosaic layout from the picture from the game



In the Utilities - Mosaic Editor menu , there are three more items that allow you to extract mosaic elements from a single image, optimize their order and quantity, and even restore the original layout.



Split drawing into mosaic - lays out the image opened in the paint path to the mosaic elements. For example, in the paintcade, open a map from the game Battle City measuring 13 by 13 elements.


The function "decompose the picture into a mosaic" lays out the map in such a mosaic, where each next element is another piece of the map (here the elements are only 16x16 pixels, therefore the displayed numbers do not fit into the cells. The mosaic editor is displayed on the left with the Details turned on, on the right - with the turned off):


Before calling this function, it is recommended to select one of the mosaic elements in the figure, and then the default sizes of the elements will be immediately equal to the size of the selection.

Delete duplicate elements - sorts the elements received using the previous function, deleting those that are repeated. The result is a total of 11 different elements:


Restore the matrix according to the figure- when we have mosaic elements sorted using the previous function, we can read their location from the map by restoring the matrix (layout of elements) for the mosaic editor. To do this: 1) load the map into the paint path; 2) call this function and specify one of the sorted mosaic elements (you can work with unsorted elements, but it will be longer, because there are more of them). And as a result, at the end of the function, the mosaic editor opens in which the recognized matrix is ​​visible (layout of elements):


The resulting layout can be saved and used together with the elements themselves, for example, in your own game about tanks. Although it is certainly better to draw your own elements, plagiarizing is not good. Yes, and in the game about tanks, in fact (most likely), the map consists of much smaller pieces (8x8 pixels or a fourth of our received 16x16, although in the map editor the tanks use 16x16 elements - they are crumbled by tank cartridges not entirely, but bit by bit, the bricks generally crumble into small pieces). So you can try to do the same with this card with an emphasis on 8x8 elements.

Epilogue


Now you know how you can create your translucent PNG image in PaintCAD 4Windows, assemble and video-edit your AVI animation from BMP / JPG frames, extract frames from any AVI file, and even draw your own mosaic and create a map layout for your game.

For those who first learned about the paint editor PaintCAD 4Windows: at the moment it weighs 10,879 KB and is located at blackstrip.ru/pcw.rar

Also popular now: