A method and apparatus for providing a pixel picture
By encoding pixel art with colors and coordinates and storing the data using MySQL and Redis databases, the problem of low pixel art rendering efficiency was solved, achieving efficient pixel art display.
Patent Information
- Application Number
- CN202210473745.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-29
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2042-04-29
AI Technical Summary
In existing technologies, the way pixel art is presented fails to effectively meet user needs, and how to better provide pixel art display has become an urgent problem to be solved.
The pixel art is processed using color encoding and coordinate encoding. Basic information and canvas data are stored in MySQL and Redis databases, respectively. The client decodes the pixel art based on this information.
It implements a simple encoding and decoding method, improves data access efficiency, reduces the number of accesses to databases with slow reading speeds, and improves the rendering efficiency of pixel art.
Smart Images

Figure CN115033601B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of digital images, and more particularly to a method and apparatus for providing pixel art. Background Technology
[0002] Pixel art is gaining popularity. In pixel art, pixels are presented on the canvas in clearly visible, distinct sizes (i.e., individual grids). How to better provide users with a visually appealing representation of pixel art is a pressing issue that needs to be addressed. Summary of the Invention
[0003] To overcome the problems existing in related technologies, embodiments of the present invention provide a method and apparatus for providing pixel art. The technical solution is as follows:
[0004] According to a first aspect of an embodiment of the present invention, a method for providing pixel art is provided, comprising:
[0005] Receive a request from the client to provide pixel art;
[0006] The basic information of the pixel art is obtained from the first database, including the canvas width, canvas height and color code table;
[0007] The canvas data of the pixel painting is obtained from the second database. The canvas data includes: encoded data obtained by color encoding and coordinate encoding of the pixel painting in units of visually visible pixel units. The color encoding is performed according to the color code table.
[0008] The basic information and canvas data are sent to the client so that the client can decode the requested pixel art based on the basic information and canvas data.
[0009] In one embodiment, the method further includes:
[0010] For each visually visible pixel unit in the pixel art: obtain the color code corresponding to the color of the pixel unit according to the color code table; calculate the offset of the pixel unit's position in the encoded data according to the preset coordinate transformation formula;
[0011] Arrange the color codes of all pixel units according to their corresponding offsets to obtain the encoded data;
[0012] The basic information of the pixel art is sent to a first database for storage, and the encoded data of the pixel art is sent to a second database for storage.
[0013] In one embodiment,
[0014] The color code table uses preset bits to represent colors;
[0015] The preset coordinate transformation formula includes: offset = x + y * canvas width, where x and y represent the horizontal and vertical coordinates of a pixel unit, and offset is the offset of the pixel unit in the encoded data.
[0016] In one embodiment, the first database includes a MySQL database, and the second database includes a Redis database.
[0017] According to a second aspect of an embodiment of the present invention, an apparatus for providing pixel art is provided, comprising:
[0018] The receiving module is used to receive requests from clients to provide pixel art.
[0019] The first acquisition module is used to acquire basic information of the pixel painting from the first database. The basic information includes canvas width, canvas height and color code table.
[0020] The second acquisition module is used to acquire the canvas data of the pixel painting from the second database. The canvas data includes: encoded data obtained by color encoding and coordinate encoding of the pixel painting in units of visually visible pixel units. The color encoding is performed according to the color code table.
[0021] The sending module is used to send the basic information and canvas data to the client so that the client can decode the requested pixel art based on the basic information and canvas data.
[0022] In one embodiment, the apparatus further includes an encoding module for:
[0023] For each visually visible pixel unit in the pixel art: obtain the color code corresponding to the color of the pixel unit according to the color code table; calculate the offset of the pixel unit's position in the encoded data according to the preset coordinate transformation formula;
[0024] Arrange the color codes of all pixel units according to their corresponding offsets to obtain the encoded data;
[0025] The basic information of the pixel art is sent to a first database for storage, and the encoded data of the pixel art is sent to a second database for storage.
[0026] In one embodiment, the color code table uses a preset bit to represent the color;
[0027] The preset coordinate transformation formula includes: offset = x + y * canvas width, where x and y represent the horizontal and vertical coordinates of a pixel unit, and offset is the offset of the pixel unit in the encoded data.
[0028] According to a third aspect of an embodiment of the present invention, an apparatus for providing pixel art is provided, characterized in that it comprises:
[0029] processor;
[0030] Memory used to store processor-executable instructions;
[0031] The processor is configured as follows:
[0032] The basic information of the pixel art is obtained from the first database, including the canvas width, canvas height and color code table;
[0033] The canvas data of the pixel painting is obtained from the second database. The canvas data includes: encoded data obtained by color encoding and coordinate encoding of the pixel painting in units of visually visible pixel units. The color encoding is performed according to the color code table.
[0034] The basic information and canvas data are sent to the client so that the client can decode the requested pixel art based on the basic information and canvas data.
[0035] According to a fourth aspect of an embodiment of the present invention, a computer-readable storage medium is provided having computer instructions stored thereon, characterized in that, when executed by a processor, the instructions implement the steps of any of the methods in the first aspect of the embodiments of the present invention.
[0036] In the technical solution provided by the embodiments of the present invention, the pixel painting is encoded by color encoding and coordinate encoding, taking the visually visible pixel units in the pixel painting as the unit. The encoding and decoding method is simple and does not require complex calculations. Furthermore, the encoded data is stored in two databases according to its characteristics. The server obtains the encoded pixel painting data by accessing the two databases, which is highly efficient.
[0037] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the invention. Attached Figure Description
[0038] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0039] Figure 1 This is a flowchart illustrating a method for providing pixel art according to an exemplary embodiment;
[0040] Figure 2 This is a schematic diagram of a color code table according to an exemplary embodiment;
[0041] Figure 3This is a schematic diagram illustrating pixel art encoding according to an exemplary embodiment;
[0042] Figure 4 This is a schematic diagram illustrating pixel art decoding according to an exemplary embodiment;
[0043] Figure 5 This is a flowchart illustrating a method for providing pixel art according to an exemplary embodiment;
[0044] Figure 6 This is a block diagram illustrating an apparatus for providing pixel art according to an exemplary embodiment.
[0045] Figure 7 This is a block diagram illustrating an apparatus for providing pixel art according to an exemplary embodiment.
[0046] Figure 8 This is a block diagram illustrating an apparatus for providing pixel art according to an exemplary embodiment. Detailed Implementation
[0047] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims.
[0048] Embodiments of the present invention provide a method for providing pixel art, which can be applied to a server to provide pixel art according to client requests. Figure 1 As shown, the method includes the following steps 101 to 105:
[0049] In step 101, a request to provide pixel art is received from the client.
[0050] The client could be an app installed on the user's device. Once the user enters the app, the client sends a request to the server to provide the pixel art, thus displaying the pixel art to the user. Alternatively, the app could display thumbnails of several pixel art images; when the user selects a particular pixel art image, the client sends a request to the server to provide that image.
[0051] In step 102, basic information of the pixel painting is obtained from the first database. The basic information includes canvas width, canvas height, and color code table.
[0052] Here, canvas width and canvas height refer to the canvas width and height of the pixel art requested by the client, respectively. Pixel art is typically presented using visually visible (i.e., visible to the naked eye) pixel units. Information such as canvas width and height can be represented by the number of pixel units. The color code table is pre-set; its function is to pre-encode the pixel art according to the color code table and for the client to decode the pixel art using the color code table. The specific scheme for encoding the pixel art will be described in detail below. In one embodiment, the color code table uses preset bits to represent colors; for example, four bits can represent 16 colors. Figure 2 As shown, the binary codes corresponding to the hexadecimal codes of 16 colors are schematically illustrated. Hexadecimal codes are typically used to represent colors.
[0053] In one embodiment, the first database may include a MySQL database, which is powerful for persistently storing data to disk, but has a relatively slow read speed.
[0054] In step 103, the canvas data of the pixel painting is obtained from the second database. The canvas data includes encoded data obtained by color encoding and coordinate encoding of the pixel painting, taking the visually visible pixel units as units. The color encoding is performed according to the color code table.
[0055] The second database stores encoded pixel art data. In one embodiment, the second database can be a Redis database, which is used to store frequently accessed data in a cache for fast read speeds.
[0056] The advantage of storing the basic information of pixel art and the canvas data in two separate databases is that frequently used data is stored in the database with fast read speed, reducing the number of times the slower database is accessed, thus improving operating efficiency.
[0057] In step 104, the basic information and canvas data are sent to the client so that the client can decode the requested pixel art based on the basic information and canvas data.
[0058] Once the client receives the basic information and canvas data, it will decode the canvas data based on the canvas width, canvas height, and color code table in the basic information to obtain the original pixel art.
[0059] In the technical solution provided by the embodiments of the present invention, the pixel painting is encoded by color encoding and coordinate encoding, taking the visually visible pixel units as the unit. The encoding and decoding method is simple and does not require complex calculations. Furthermore, the encoded data is stored in two databases respectively. The server obtains the encoded data of the pixel painting by reading these two databases, which is highly efficient.
[0060] In one embodiment, the method further includes a step of encoding the pixel art, for example, the step of encoding the pixel art may include: steps A1 to A3:
[0061] Step A1: For each visually visible pixel unit in the pixel art: obtain the color code corresponding to the color of the pixel unit according to the color code table; calculate the offset of the pixel unit's position in the encoded data according to the preset coordinate transformation formula.
[0062] Step A2: Arrange the color codes of all pixel units according to their corresponding offsets to obtain the encoded data;
[0063] like Figure 3 The diagram illustrates a pixel art encoding method. For example, encoding a 2x2 pixel image, such as for pixel unit (0,0) (where a pixel unit refers to a visible cell in the pixel art), its color is red (hexadecimal code #d71345), according to... Figure 2 The example uses a preset color code table to encode colors; the color code for the (0,0) pixel unit is 0101. The coordinates of the (0,0) pixel unit also need to be encoded. This encoding can be done using the following formula: offset = x + y * canvas width, where x and y are the horizontal and vertical coordinates of the pixel unit, respectively, and the canvas width refers to the horizontal number of pixel units drawn in the image (2 in this example). The calculated offset is the offset of the encoded data for that pixel unit from all the encoded data. For example, all encoded data can be stored in a list. Based on the above formula, the offset of the (0,0) pixel unit is calculated to be 0.
[0064] For example, for the (0,1) pixel unit, its color is yellow (hexadecimal code #ffc20e), according to... Figure 2The example uses a preset color code table to encode colors; the color code for pixel unit (0,1) is 0110. The coordinates of pixel unit (0,1) also need to be encoded. Again, according to the above formula, the calculated offset is the offset of the encoded data for that pixel unit within all encoded data. According to the above formula, the offset for pixel unit (0,0) is calculated to be 1. This process can be repeated to encode each pixel unit in the pixel art. The encoded data can be, for example, a table storing the color code of each pixel unit according to the calculated offset. Those skilled in the art should understand that pixel art encoding can be performed by any applicable terminal; this application does not limit the executing entity.
[0065] Step A3: Send the basic information of the pixel art to the first database for storage, and send the encoded data of the pixel art to the second database for storage.
[0066] The pixel art encoding scheme proposed in this embodiment consumes minimal storage; for a 10,000-grid pixel art on a 16-color canvas, the encoded data size is only approximately 4kB. In one embodiment, after encoding the pixel art, basic information such as the color code table, canvas width, and canvas height can be stored in a MySQL database. The encoded canvas data, i.e., the table storing the color code of each pixel according to its offset, can be stored in a Redis database. The data stored in the database is used to retrieve the pixel art when the client requests it.
[0067] After step 104 sends the basic information of the pixel art and the canvas data to the client, the client decodes the requested pixel art based on this information. The decoding process is the inverse operation of the encoding process. For example... Figure 4 As shown, after receiving the basic information of the pixel art and the canvas data sent by the server, the client decodes the color of each pixel unit according to the 4-bit encoding in the canvas data and the preset color code table, and obtains the horizontal and vertical coordinates of the corresponding pixel unit based on the offset of each 4-bit encoding in the table. The coordinate transformation formula is, for example:
[0068] x-axis = offset % canvas width (remainder);
[0069] The vertical axis y = offset / canvas width (round down if there is a remainder).
[0070] The implementation process will be described in detail below through examples.
[0071] Figure 5 This is a schematic flowchart illustrating a method for providing pixel art according to an exemplary embodiment. Figure 5 As shown, it includes the following steps:
[0072] Step 501: The client APP sends a request for pixel art to the server.
[0073] Step 502: The server sends a request to the database MySQL to obtain the basic canvas information of the pixel art.
[0074] Step 503: The MySQL database returns basic canvas information to the server. This basic canvas information includes fixed information such as canvas width, canvas height, and color code table.
[0075] Step 504: The server sends a request to the Redis database to retrieve the canvas data of the pixel drawing.
[0076] Step 505: The Redis database sends canvas data to the server.
[0077] If the canvas data of the pixel art is large, for example, if the pixel art contains 10,000 squares, then a loop can be used to traverse it, obtaining a preset amount of canvas data each time, that is, repeating steps 504 and 505 until all canvas data is obtained.
[0078] Step 506: The server sends the basic canvas information and canvas data to the client APP so that the client can decode the requested pixel art based on the received basic information and canvas data.
[0079] The following are embodiments of the apparatus of the present invention, which can be used to execute embodiments of the method of the present invention.
[0080] Figure 6 This is a block diagram illustrating an apparatus for providing pixel art according to an exemplary embodiment. The apparatus for providing pixel art can be a server or part of a server, or a terminal or part of a terminal. The apparatus for providing pixel art can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 6 As shown, the device for providing pixel art includes:
[0081] The receiving module 601 is used to receive a request from the client to provide a pixel art image;
[0082] The first acquisition module 602 is used to acquire basic information of the pixel painting from the first database. The basic information includes canvas width, canvas height and color code table.
[0083] The second acquisition module 603 is used to acquire the canvas data of the pixel painting from the second database. The canvas data includes: encoded data obtained by color encoding and coordinate encoding of the pixel painting in units of visually visible pixel units. The color encoding is performed according to the color code table.
[0084] The sending module 604 is used to send the basic information and canvas data to the client so that the client can decode the requested pixel art based on the basic information and canvas data.
[0085] In one embodiment, the apparatus further includes an encoding module for:
[0086] For each visually visible pixel unit in the pixel art: obtain the color code corresponding to the color of the pixel unit according to the color code table; calculate the offset of the pixel unit's position in the encoded data according to the preset coordinate transformation formula;
[0087] Arrange the color codes of all pixel units according to their corresponding offsets to obtain the encoded data;
[0088] The basic information of the pixel art is sent to a first database for storage, and the encoded data of the pixel art is sent to a second database for storage.
[0089] In one embodiment, the color code table represents color using a preset bit; the preset coordinate transformation formula includes: offset = x + y * canvas width, where x and y represent the horizontal and vertical coordinates of a pixel unit, and offset is the offset of the pixel unit in the encoded data.
[0090] Embodiments of the present invention provide an apparatus for providing pixel art, which encodes the pixel art in units of visually visible pixels. The encoding and decoding method is simple and does not require complex calculations. Furthermore, the encoded data is stored in two databases according to its characteristics. The server obtains the encoded pixel art data through these two databases, which is highly efficient.
[0091] Figure 7 This is a block diagram illustrating an apparatus 70 for providing pixel art according to an exemplary embodiment. The apparatus for providing pixel art can be a server or part of a server, or a terminal or part of a terminal. The apparatus for providing pixel art includes:
[0092] Processor 701;
[0093] Memory 702 is used to store executable instructions of processor 701;
[0094] The processor 701 is configured as follows:
[0095] The basic information of the pixel art is obtained from the first database, including the canvas width, canvas height and color code table;
[0096] The canvas data of the pixel painting is obtained from the second database. The canvas data includes: encoded data obtained by color encoding and coordinate encoding of the pixel painting in units of visually visible pixel units. The color encoding is performed according to the color code table.
[0097] The basic information and canvas data are sent to the client so that the client can decode the requested pixel art based on the basic information and canvas data.
[0098] Figure 8 This is a block diagram illustrating an apparatus 800 for providing pixel art according to an exemplary embodiment. The apparatus may be a computer, server, etc.
[0099] The device may include one or more of the following components: processing component 802, memory 804, power supply component 806, multimedia component 808, audio component 810, input / output (I / O) interface 812, sensor component 814, and communication component 816.
[0100] Processing component 802 typically controls the overall operation of device 800, such as operations associated with display, telephone calls, data communication, camera operation, and recording operations. Processing component 802 may include one or more processors 820 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 802 may include one or more modules to facilitate interaction between processing component 802 and other components. For example, processing component 802 may include a multimedia module to facilitate interaction between multimedia component 808 and processing component 802.
[0101] Memory 804 is configured to store various types of data to support the operation of device 800. Examples of such data include instructions for any application or method operating on device 800, contact data, phonebook data, messages, pictures, videos, etc. Memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0102] Power supply component 806 provides power to various components of device 800. Power supply component 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to device 800.
[0103] Multimedia component 808 includes a screen that provides an output interface between device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 808 includes a front-facing camera and / or a rear-facing camera. When device 800 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0104] Audio component 810 is configured to output and / or input audio signals. For example, audio component 810 includes a microphone (MIC) configured to receive external audio signals when device 800 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 804 or transmitted via communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
[0105] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0106] Sensor assembly 814 includes one or more sensors for providing status assessments of various aspects of device 800. For example, sensor assembly 814 may detect the on / off state of device 800, the relative positioning of components such as the display and keypad of device 800, changes in the position of device 800 or a component of device 800, the presence or absence of user contact with device 800, the orientation or acceleration / deceleration of device 800, and temperature changes of device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 814 may also include an accelerometer, a gyroscope, a magnetometer, a pressure sensor, or a temperature sensor.
[0107] Communication component 816 is configured to facilitate wired or wireless communication between device 800 and other devices. Device 800 can access wireless networks based on communication standards, such as walkie-talkie networks, WiFi, 2G, 3G, 4G, or 5G, or combinations thereof. In one exemplary embodiment, communication component 816 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 816 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0108] In an exemplary embodiment, the apparatus 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0109] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, which can be executed by a processor 820 of the device 800 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0110] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of a device 800, enables the device 800 to perform the aforementioned method for providing pixel art, the method comprising:
[0111] Receive a request from the client to provide pixel art;
[0112] The basic information of the pixel art is obtained from the first database, including the canvas width, canvas height and color code table;
[0113] The canvas data of the pixel painting is obtained from the second database. The canvas data includes: encoded data obtained by color encoding and coordinate encoding of the pixel painting in units of visually visible pixel units. The color encoding is performed according to the color code table.
[0114] The basic information and canvas data are sent to the client so that the client can decode the requested pixel art based on the basic information and canvas data.
[0115] Other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention described herein. This application is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not invented herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of the invention are indicated by the following claims.
[0116] It should be understood that the present invention is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
Claims
1. A method for providing pixel art, characterized in that, include: Receive a request from a client to provide a pixel art, wherein the client is an APP installed on a user terminal, and the pixel art is presented in visually visible pixel units; The basic information of the pixel art is obtained from a first database, which includes canvas width, canvas height and color code table, wherein the first database includes a MySQL database; The canvas data of the pixel painting is obtained from the second database, wherein the canvas data includes: encoded data obtained by color encoding and coordinate encoding of the pixel painting in units of visually visible pixel units, wherein the color encoding is performed according to the color code table, and the second database includes a Redis database; The basic information and canvas data are sent to the client so that the client can decode the requested pixel art based on the basic information and canvas data. The method further includes: For each visually visible pixel unit in the pixel art: obtain the color code corresponding to the color of the pixel unit according to the color code table; calculate the offset of the pixel unit's position in the encoded data according to the preset coordinate transformation formula, wherein the preset coordinate transformation formula includes: offset = x + y * canvas width, where x and y represent the horizontal and vertical coordinates of the pixel unit, and offset is the offset of the pixel unit in the encoded data. Arrange the color codes of all pixel units according to their corresponding offsets to obtain the encoded data; The basic information of the pixel art is sent to the first database for storage, and the encoded data of the pixel art is sent to the second database for storage. The color code table uses preset bits to represent colors; The step of enabling the client to decode the requested pixel art based on the basic information and canvas data includes: Based on the 4-bit encoding in the canvas data and the preset color code table, the color of each pixel unit is decoded, and the horizontal and vertical coordinates of the corresponding pixel unit are obtained according to the offset of each 4-bit encoding in the table.
2. An apparatus for providing pixel art, characterized in that, include: The receiving module is used to receive a request from a client to provide a pixel art, wherein the client is an APP installed on a user terminal, and the pixel art is presented in visually visible pixel units; The first acquisition module is used to acquire basic information of the pixel painting from the first database. The basic information includes canvas width, canvas height and color code table. The first database includes a MySQL database. The second acquisition module is used to acquire the canvas data of the pixel painting from the second database. The canvas data includes: encoded data obtained by color encoding and coordinate encoding of the pixel painting in units of visually visible pixel units. The color encoding is performed according to the color code table. The second database includes a Redis database. The sending module is used to send the basic information and canvas data to the client so that the client can decode the requested pixel art based on the basic information and canvas data. The device further includes an encoding module, used for: For each visually visible pixel unit in the pixel art: obtain the color code corresponding to the color of the pixel unit according to the color code table; calculate the offset of the pixel unit's position in the encoded data according to the preset coordinate transformation formula, wherein the preset coordinate transformation formula includes: offset = x + y * canvas width, where x and y represent the horizontal and vertical coordinates of the pixel unit, and offset is the offset of the pixel unit in the encoded data. Arrange the color codes of all pixel units according to their corresponding offsets to obtain the encoded data; The basic information of the pixel art is sent to the first database for storage, and the encoded data of the pixel art is sent to the second database for storage. The color code table uses preset bits to represent colors; The step of enabling the client to decode the requested pixel art based on the basic information and canvas data includes: Based on the 4-bit encoding in the canvas data and the preset color code table, the color of each pixel unit is decoded, and the horizontal and vertical coordinates of the corresponding pixel unit are obtained according to the offset of each 4-bit encoding in the table.
3. An apparatus for providing pixel art, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured as follows: Receive a request from a client to provide a pixel art, wherein the client is an APP installed on a user terminal, and the pixel art is presented in visually visible pixel units; The basic information of the pixel art is obtained from a first database, which includes canvas width, canvas height and color code table, wherein the first database includes a MySQL database; The canvas data of the pixel painting is obtained from the second database, wherein the canvas data includes: encoded data obtained by color encoding and coordinate encoding of the pixel painting in units of visually visible pixel units, wherein the color encoding is performed according to the color code table, and the second database includes a Redis database; The basic information and canvas data are sent to the client so that the client can decode the requested pixel art based on the basic information and canvas data. The color code table uses preset bits to represent colors; The step of enabling the client to decode the requested pixel art based on the basic information and canvas data includes: Based on the 4-bit encoding in the canvas data and the preset color code table, the color of each pixel unit is decoded, and the horizontal and vertical coordinates of the corresponding pixel unit are obtained based on the offset of each 4-bit encoding in the table. The processor is also configured to: For each visually visible pixel unit in the pixel art: obtain the color code corresponding to the color of the pixel unit according to the color code table; calculate the offset of the pixel unit's position in the encoded data according to the preset coordinate transformation formula, wherein the preset coordinate transformation formula includes: offset = x + y * canvas width, where x and y represent the horizontal and vertical coordinates of the pixel unit, and offset is the offset of the pixel unit in the encoded data. Arrange the color codes of all pixel units according to their corresponding offsets to obtain the encoded data; The basic information of the pixel art is sent to a first database for storage, and the encoded data of the pixel art is sent to a second database for storage.
4. A computer-readable storage medium storing computer instructions thereon, characterized in that, When executed by the processor, this instruction implements the steps of the method of claim 1.
Citation Information
Patent Citations
Method and system operative to process color image data
CN102542270A
Page generation method, apparatus and device, and readable storage medium
CN110502710A
Image coding method and device, image decoding method and device, electronic equipment and storage medium
CN112911303A