CN110189384B - Image compression method, device, computer equipment and storage medium based on Unity3D - Google Patents

Image compression method, device, computer equipment and storage medium based on Unity3D Download PDF

Info

Publication number
CN110189384B
CN110189384B CN201810153558.1A CN201810153558A CN110189384B CN 110189384 B CN110189384 B CN 110189384B CN 201810153558 A CN201810153558 A CN 201810153558A CN 110189384 B CN110189384 B CN 110189384B
Authority
CN
China
Prior art keywords
textures
texture
color
attribute information
compression mode
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810153558.1A
Other languages
Chinese (zh)
Other versions
CN110189384A (en
Inventor
朱必灯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Menggu Interactive Network Co ltd
Original Assignee
Shenzhen Menggu Interactive Network Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Menggu Interactive Network Co ltd filed Critical Shenzhen Menggu Interactive Network Co ltd
Priority to CN201810153558.1A priority Critical patent/CN110189384B/en
Publication of CN110189384A publication Critical patent/CN110189384A/en
Application granted granted Critical
Publication of CN110189384B publication Critical patent/CN110189384B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T9/00Image coding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/186Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being a colour or a chrominance component

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Signal Processing (AREA)
  • Compression Of Band Width Or Redundancy In Fax (AREA)

Abstract

The application relates to a Unity 3D-based image compression method, a Unity 3D-based image compression device, computer equipment and a storage medium. The method comprises the following steps: acquiring a texture image file in Unity 3D; determining attribute information of the texture image file; when the determined attribute information meets a preset condition, acquiring a target compression mode matched with the attribute information; separating color textures and Alpha channel textures from the texture image file; compressing the color textures in the acquired target compression mode; and combining the compressed color textures with the Alpha channel textures to obtain compressed texture image files for display on the mobile terminal. The method can avoid the problem that the compressed image has color gradation in the display process of the mobile terminal.

Description

Image compression method, device, computer equipment and storage medium based on Unity3D
Technical Field
The present disclosure relates to the field of image compression technologies, and in particular, to a method, an apparatus, a computer device, and a storage medium for image compression based on Unity 3D.
Background
Digital images generally require a large number of bits, which brings about considerable examination on the transmission and storage of digital images, and greatly restricts the development of image processing, so that image compression techniques have received a great deal of attention.
The purpose of image compression is to represent the original larger image with the least number of bits and to display the compressed image with better quality. In the traditional image compression scheme, a specific image compression algorithm is adopted to directly compress the image, so that the space for storing the image is greatly saved. However, with the above-described image compression scheme, there is a possibility that a compressed image has a significant color gradation, resulting in a problem of image distortion.
Disclosure of Invention
Based on this, it is necessary to provide a Unity 3D-based image compression method, device, computer equipment and storage medium for the above technical problem that the compressed image has a significant color level in the display process.
A Unity 3D-based image compression method, the method comprising:
acquiring a texture image file in Unity 3D;
determining attribute information of the texture image file;
when the determined attribute information meets a preset condition, acquiring a target compression mode matched with the attribute information;
separating color textures and Alpha channel textures from the texture image file;
compressing the color textures in the acquired target compression mode;
And combining the compressed color textures with the Alpha channel textures to obtain compressed texture image files for display on the mobile terminal.
An Unity 3D-based image compression apparatus, the apparatus comprising:
the file acquisition module is used for acquiring texture image files in the Unity 3D;
the attribute information determining module is used for determining attribute information of the texture image file;
the compression mode acquisition module is used for acquiring a target compression mode matched with the attribute information when the determined attribute information meets a preset condition;
the separation module is used for separating color textures and Alpha channel textures from the texture image file;
the compression module is used for compressing the color textures in the acquired target compression mode;
and the combination module is used for combining the compressed color textures with the Alpha channel textures to obtain compressed texture image files for displaying on the mobile terminal.
A computer device comprising a memory storing a computer program and a processor which when executing the computer program performs the steps of:
acquiring a texture image file in Unity 3D;
Determining attribute information of the texture image file;
when the determined attribute information meets a preset condition, acquiring a target compression mode matched with the attribute information;
separating color textures and Alpha channel textures from the texture image file;
compressing the color textures in the acquired target compression mode;
and combining the compressed color textures with the Alpha channel textures to obtain compressed texture image files for display on the mobile terminal.
A computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
acquiring a texture image file in Unity 3D;
determining attribute information of the texture image file;
when the determined attribute information meets a preset condition, acquiring a target compression mode matched with the attribute information;
separating color textures and Alpha channel textures from the texture image file;
compressing the color textures in the acquired target compression mode;
and combining the compressed color textures with the Alpha channel textures to obtain compressed texture image files for display on the mobile terminal.
According to the image compression method, the device, the computer equipment and the storage medium based on the Unity3D, the attribute information of the texture image file is determined, the target compression mode matched with the attribute information is obtained, and the relation between the compression mode and the texture image file is established, so that the matched compression mode is selected in a targeted manner, and the image quality of the compressed texture image file is improved. The color textures in the texture image file are compressed in the acquired target compression mode, and the compressed color textures and Alpha channel textures are combined, so that the compression of the texture image is realized, and meanwhile, the generation of color gradation caused by the compressed Alpha channel textures is avoided, and the problem of distortion of the texture image file is avoided.
Drawings
FIG. 1 is an application environment diagram of a Unity 3D-based image compression method in one embodiment;
FIG. 2 is an internal block diagram of a computer device in one embodiment;
FIG. 3 is a flow diagram of a method of Unity 3D-based image compression in one embodiment;
FIG. 4 is a flowchart illustrating steps for compressing RGB color textures in one embodiment;
FIG. 5 is a flowchart illustrating steps for obtaining a target compression method according to attribute information, display resolution and operation system identifier, and compressing RGB color textures in another embodiment;
FIG. 6 is a flowchart illustrating steps for obtaining a target compression method according to keywords in a file name and compressing RGB color textures in one embodiment;
FIG. 7 is a schematic diagram of a texture image file before compression and after compression, in one embodiment;
FIG. 8 is a schematic diagram of a 3D island map and a UI full screen map in one embodiment;
FIG. 9 is a flowchart of a method for compressing images based on Unity3D according to another embodiment;
fig. 10 is a block diagram illustrating a structure of an image compression apparatus based on Unity3D in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
The image compression method based on the Unity3D can be applied to an application environment shown in figure 1. Wherein the mobile terminals 102, 106 communicate with the server 104 over a network. The terminal 106 obtains a texture image file in the Unity3D, determines attribute information of the texture image file, obtains a target compression mode adapted to the attribute information when the determined attribute information meets a preset condition, separates color textures and Alpha channel textures from the texture image file, compresses the color textures through the obtained target compression mode, and combines the compressed color textures and Alpha channel textures to obtain the compressed texture image file for display on the mobile terminal. The terminal 106 transmits the compressed texture image file to the server 104, and the mobile terminal 102 downloads the texture image file from the server 104 via a network and displays the texture image file. The mobile terminal 102 may be, but not limited to, a smart phone, a tablet computer, and a portable wearable device, the server 104 may be implemented by a stand-alone server or a server cluster formed by a plurality of servers, and the terminal 106 may be, but not limited to, various personal computers, notebook computers, tablet computers, and the like.
FIG. 2 is a schematic diagram of the internal structure of a computer device in one embodiment. As shown in fig. 2, the computer device includes a processor, a non-volatile storage medium, an internal memory, a network interface, a display screen, and an input device connected by a system bus. The non-volatile storage medium of the computer equipment is stored with an operating system, a database and a Unity 3D-based image compression device, wherein the database is stored with a target linear element on a map and a line marking pattern and a point marking pattern corresponding to the target current element, and the Unity 3D-based image compression device is used for realizing a Unity 3D-based image compression method suitable for the computer equipment. The processor of the computer device is used to provide computing and control capabilities, supporting the operation of the entire computer device. The internal memory of the computer device provides an environment for the operation of the Unity 3D-based image compression means in a non-volatile storage medium, and computer readable instructions may be stored in the internal memory, which when executed by the processor, cause the processor to perform a Unity 3D-based image compression method. The network interface of the computer device is used for transmitting map-related data. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, the input device of the computer equipment can be a touch layer covered on the display screen, can also be keys, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like. The computer device may be the terminal 106 of fig. 1. It will be appreciated by those skilled in the art that the structure shown in fig. 2 is merely a block diagram of some of the structures associated with the present application and is not limiting of the computer device to which the present application may be applied, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, as shown in fig. 3, there is provided a Unity 3D-based image compression method, which is illustrated by taking the application of the method to the terminal 106 in fig. 1 as an example, and includes the following steps:
step 302, obtaining a texture image file in Unity 3D.
Here, unity3D refers to a development tool for creating contents such as a visual building, a three-dimensional image, and a three-dimensional animation, and can be installed in a terminal. The terminal can manufacture various three-dimensional texture images through the Unity3D, and corresponding texture image files are generated according to the manufactured texture images.
Texture includes texture of the object surface (e.g., grooves that make the object surface appear to be rugged) and color patterns of the object surface. The texture image file refers to an image file containing textures, wherein the texture image file includes at least one of a POT map file with Alpha channels, a POT map file without Alpha channels, and an NPOT map file. The texture image file comprises a color texture and an Alpha channel texture, the color texture can be an RGB color texture, the Alpha channel texture can be a transparent channel texture, and the color texture and the Alpha channel texture can be separated from the texture image file. Furthermore, the Alpha channel texture may also be an opaque or translucent channel texture.
In one embodiment, the terminal receives the texture image file in the network, or selects the texture image file from the local image library, and when the texture image file is loaded into Unity3D according to the trigger event, the texture image file in Unity3D is obtained. Wherein the trigger event may be an input operation instruction.
In one embodiment, the terminal performs image processing and rendering on the texture image in the Unity3D, and after performing the image processing and rendering, forms a texture image file in a corresponding format according to the texture image after the image processing and rendering, thereby obtaining the texture image file in the Unity 3D.
In step 304, attribute information of the texture image file is determined.
Wherein the attribute information may include a file size and a texture type in addition to a file name of the texture image file. Texture types include POT texture with Alpha channels, POT texture without Alpha channels, and NPOT texture. The terminal can acquire a corresponding target compression mode according to the attribute information so as to compress the texture image file according to the target compression mode.
In one embodiment, the terminal acquires a file name of the texture image file, and determines attribute information in the file name according to the acquired file name. For example, the terminal acquires the file name of the texture image file as xyDither565, from which the attribute information of the texture image file can be determined as Dither565.
In one embodiment, the terminal determines whether the texture image file contains an Alpha channel texture and has a POT texture, and determines attribute information of the texture image file according to whether the texture image file contains the Alpha channel texture and has the POT texture.
And 306, when the determined attribute information meets the preset condition, acquiring a target compression mode matched with the attribute information.
The target compression method may include a dith 565 compression method, and may further include an ETC compression method and a PVRTC compression method.
In one embodiment, when the attribute information is a file name, the terminal determines whether the file name satisfies a preset keyword, and if so, obtains a target compression mode adapted to the file name. For example, when the preset keyword Dither565 is included according to the file name, the terminal acquires the compression mode of the Dither565 corresponding to the Dither 565.
In one embodiment, when the attribute information is a file size, the terminal determines whether the file size is greater than a preset file size threshold, and if so, obtains a target compression mode, or obtains a target compression mode corresponding to the file size. When the attribute information is the file size and the file size is smaller than the preset file size threshold, the terminal does not need to compress the texture image file. For example, when the determined file size is greater than t megabits (M), the terminal obtains a corresponding Dither565 compression scheme. Wherein t is more than or equal to 1 and less than or equal to 100.
In one embodiment, when the attribute information is a texture type, the terminal determines whether the texture type meets a preset texture type, and if yes, acquires a target compression mode corresponding to the texture type. For example, when the attribute information is a POT texture with an Alpha channel, a POT texture without an Alpha channel, or an NPOT texture, it is indicated that the preset texture type is satisfied, and the terminal obtains a Dither565 compression mode corresponding to Dither 565. In addition, when the attribute information is POT texture without Alpha channel, ECT1 compression mode can be adopted.
Step 308, separating the color texture and Alpha channel texture from the texture image file.
Specifically, color textures and Alpha channel textures are separated from the texture image file through Unity3D, and a file of the color textures and a file of the Alpha channel textures are obtained.
In one embodiment, the terminal separates the Alpha channel texture from the texture image file through Unity3D, and then converts the texture image file into a texture image that does not contain the Alpha channel texture format, thereby obtaining a file of color textures. For example, alpha channel textures in a png format texture image file are extracted, and then the png format texture image file is converted into a jpg format texture image, thereby obtaining a color texture file.
In step 310, the color textures are compressed by the obtained target compression method.
Wherein RGB represents the colors of the three channels red, green and blue, respectively. Thus, the color textures may include RGB color textures.
Specifically, the terminal compresses color textures of three red, green and blue channels with 8 channel bits into red, green and blue color textures with channels smaller than 8 bits by adopting a target compression mode through Unity 3D.
In one embodiment, the terminal selects a matching preset color value for each pixel in the color texture, calculates the error between the preset color value and the primary color value. When the error between the primary color value of the current pixel and the preset color value is calculated, the terminal diffuses the calculated error to the pixel adjacent to the current pixel to obtain the color texture subjected to error diffusion treatment, and the color texture subjected to error diffusion is compressed in a target compression mode.
Step 312, combining the compressed color texture with the Alpha channel texture to obtain a compressed texture image file for display on the mobile terminal.
For example, after the color textures are compressed, the terminal obtains RGB color textures with 5×6×5 bits of color bits, and combines the compressed RGB color textures with Alpha channel of 8 bits to obtain texture image files with 5×6×5×8 bits of color bits respectively.
In one embodiment, if the terminal adopts a manner of compressing the texture image file in real time, the terminal may select a corresponding compression scheme according to the size of the texture image file. When the texture image file is larger, the color textures in the texture image file are compressed while being compressed, the compressed color textures and Alpha channel textures are combined, and then the combined compressed texture image file is transmitted to the mobile terminal for display until the texture image file is completely compressed and transmitted to the mobile terminal. And when the texture image file is smaller, compressing all color textures in the texture image file, combining the compressed color textures with Alpha channel textures, and transmitting the combined compressed texture image file to the mobile terminal for display.
In the above embodiment, by determining the attribute information of the texture image file, the target compression mode adapted to the attribute information is obtained, and the relationship between the compression mode and the texture image file is established, so that the adapted compression mode is selected in a targeted manner, and the image quality of the compressed texture image file is improved. The color textures in the texture image file are compressed in the acquired target compression mode, and the compressed color textures and Alpha channel textures are combined, so that the compression of the texture image is realized, and meanwhile, the generation of color gradation caused by the compressed Alpha channel textures is avoided, and the problem of distortion of the texture image file is avoided.
In one embodiment, the color textures are RGB color textures; alpha channel textures include transparent channel textures; as shown in fig. 4, step 310 may specifically include:
in step 402, the number of color bits of the RGB color textures is reduced by the obtained target compression method.
Specifically, the terminal converts the RGB color textures of high color bits into the RGB color textures of low color bits by the acquired target compression mode. For example, the RGB color texture having a color number of a×b×c is reduced to a×b×c, where A, B and C may be any one of 8, 15, 16, 24, and 32, and a, B, and C are numbers greater than 1 and less than 8.
In one embodiment, the terminal selects a matching preset color value for each pixel in the color texture, calculates the error between the preset color value and the primary color value. When the error between the primary color value of the current pixel and the preset color value is calculated, the terminal diffuses the calculated error to the pixel adjacent to the current pixel to obtain the color texture subjected to error diffusion treatment, and then reduces the color number of the RGB color texture subjected to error diffusion to obtain the RGB color texture with reduced color number.
In step 404, noise is added to the RGB color textures after the color bits are reduced, and the added noise is used for performing color smoothing on the RGB color textures after the color bits are reduced.
The noise may be gaussian white noise, rayleigh noise, and irish noise, among others.
Specifically, the terminal converts the RGB color textures of high color bits into the RGB color textures of low color bits by the acquired target compression mode, and then adds a proper amount of noise into the RGB color textures of low color bits. For example, the terminal reduces the RGB color texture having a color number of 8 x 8 to a 4 x 4 RGB color texture, then adding 1, 2 and 1 bit noise in the RGB color textures of 4 x 4, thereby obtaining a 5×6×5 RGB color texture.
In one embodiment, step 312 may specifically include: the noisy RGB color texture is combined with the Alpha channel texture.
In the above embodiment, the number of color bits of the RGB color textures is reduced by the target compression method, and noise is added to the RGB color textures with reduced number of color bits, so that the compressed RGB color textures are smoothed, the problem of sharp textures between the compressed RGB color textures is avoided, and the display effect of the RGB color textures is improved.
In one embodiment, as shown in fig. 5, step 306 may specifically include:
step 502, obtaining the resolution of a display screen and an operating system identification of the mobile terminal.
The display screen resolution refers to the resolution of screen display, and includes VGA (640×480), XGA (1024×768), UXGA (1600×1200), and the like. The operating system comprises Android (Android), iOS, windows Phone and the like, and the operating system identification refers to identification for distinguishing the operating system.
Specifically, the terminal acquires the corresponding display screen resolution and operating system identification according to a preset display screen resolution list and an operating system identification list, so as to acquire a corresponding target compression mode according to the display screen resolution and the operating system identification.
In one embodiment, if the terminal adopts a mode of compressing the texture image file in real time, the terminal receives an acquisition request carrying the resolution of the display screen and the identification of the operating system sent by the mobile terminal, and analyzes the request to obtain the resolution of the display screen and the identification of the operating system, so as to select an adaptive target compression mode aiming at the resolution of the display screen and the identification of the operating system.
Step 504, obtain the target compression mode adapted to the attribute information, the resolution of the display screen and the operating system identification.
In one embodiment, step 310 may specifically include: and compressing the color textures scaled according to the resolution of the display screen in a target compression mode.
Specifically, the terminal scales the color texture according to the resolution of the display screen so as to enable the resolution of the color texture to be consistent with the resolution of the display screen. And then, the terminal compresses the color textures scaled according to the resolution of the display screen in a target compression mode.
In one embodiment, step 312 may specifically include: and combining the compressed color textures with Alpha channel textures scaled according to the resolution of the display screen.
Specifically, the terminal scales the Alpha channel texture according to the resolution of the display screen so that the resolution of the Alpha channel texture accords with the resolution of the display screen. The terminal then combines the compressed color texture with the Alpha channel texture scaled by the display resolution.
In the above embodiment, by acquiring the resolution of the display screen and the operating system identifier of the mobile terminal and selecting the adaptive target compression mode according to the resolution of the display screen and the operating system identifier, the texture image file can be effectively compressed according to the selection of the appropriate target compression mode of different types of mobile terminals, so as to meet the requirements of the resolution and the operating system of the mobile terminal, and effectively improve the display effect of the texture image file.
In one embodiment, the attribute information includes keywords of file names of the texture image files; the target compression mode is a Dither565 compression mode; step 306 may specifically include:
step 602, importing the acquired texture image file into Unity3D.
Step 604, detecting a preset name suffix in the file name; the preset name suffix is used for identifying the texture image file adapting to the target compression mode.
For example, it is detected whether Dither565 is included in the file name.
In step 606, when the preset name suffix is detected, a Dither565 compression mode adapted to the preset name suffix is obtained, so as to compress the texture image file according to the Dither565 compression mode.
In one embodiment, the terminal converts the RGB color textures of high color bits into the RGB color textures of low color bits by the Dither565 compression mode, and then adds a proper amount of noise to the RGB color textures of low color bits.
For example, the terminal reduces the RGB color texture having a color number of 8 x 8 to a 4 x 4 RGB color texture, then adding 1, 2 and 1 bit noise in the RGB color textures of 4 x 4, thus, a 5×6×5 RGB color texture is obtained, as shown in fig. 7, where fig. 7 (a) is an original image before compression, fig. 7 (b) is an image compressed using conventional RGB 16 bits, and fig. 7 (c) is an image compressed using Dither565.
The region a in fig. 7 (b) has a distinct color level, and the region a in fig. 7 (c) has no color level problem, so that the compression scheme using Dither565 can solve the color level problem, and can perform "perfect" restoration of texture under the resolution of human eyes while maintaining the compression efficiency of 16 bits.
As an example, as shown in fig. 8 (a), 3D islands with different styles are a very important point in the game, and carry a plurality of core playing methods of the game, where the core playing methods include island establishment and island of a tapping friend, island crossing (i.e. the island of the next different theme can be unlocked after the current island establishment is completed), and so on. When the 3D island image is used as a core element and the mobile terminal displays a file of the 3D island image, the compression mode using ETC/PVRTC may cause a color level although the 3D island image is in POT format, thereby affecting the display quality of the image. At this time, the terminal uses the Dither565 compression mode to compress, the compressed texture image file can highly restore the quality of the image, in addition, higher compression efficiency can be realized, the memory size is reduced, and the loading efficiency of the texture image file is improved.
In addition, as shown in fig. 8 (b), the UI full screen is generally NPOT format, and compression mode of ETC/PVRTC cannot be used, whereas the tone scale problem in fig. 7 (b) occurs using the conventional compression mode of RGB 16bit, and the display effect is poor. Therefore, when the terminal detects that the texture type of the texture image file is in the NPOT format, the terminal compresses the texture image file by using a Dither565 compression mode.
At step 608, the system file is imported.
When the preset name suffix is detected, the terminal compresses the texture image file according to the Dither565 compression mode adapted to the preset name suffix, and the compressed texture image file is packaged in the system file. And when the preset name suffix is not detected, directly packaging the texture image file into the system file.
In the above embodiment, by detecting the keywords of the file name of the texture image file, when the corresponding keywords are detected, the corresponding Dither565 compression mode is selected according to the detected keywords, so that the problem that the RGB 16bit is adopted to generate the color level in the traditional mode is avoided, and the display effect of the texture image file is improved.
In one embodiment, as shown in fig. 9, there is provided a Unity 3D-based image compression method, which is illustrated by taking the application of the method to the terminal 106 in fig. 1 as an example, including the following steps:
step 901, obtaining a texture image file in Unity 3D.
The texture image file comprises at least one of a POT map file with Alpha channels, a POT map file without Alpha channels and an NPOT map file.
In step 902, attribute information of the texture image file is determined.
In one embodiment, step 902 may specifically include: detecting a preset name suffix in the file name; the preset name suffix is used for identifying the texture image file adapting to the target compression mode. And when the preset name suffix is detected, a Dither565 compression mode matched with the preset name suffix is acquired, so that the texture image file is compressed according to the Dither565 compression mode.
In step 903, when the determined attribute information meets the preset condition, a target compression mode adapted to the attribute information is obtained.
After acquiring the adapted target compression mode according to the attribute information, the terminal performs step 906.
Step 904, obtaining the resolution of the display screen and the identification of the operating system of the mobile terminal.
In step 905, a target compression mode adapted to the attribute information, the resolution of the display screen, and the operating system identifier is obtained.
After acquiring the adapted target compression mode according to the attribute information, the resolution of the display screen and the operating system identification, the terminal executes step 906.
Step 906, separate the color texture and Alpha channel texture from the texture image file.
In step 907, the color textures are compressed by the obtained target compression method.
In one embodiment, step 907 specifically includes: and reducing the number of color bits of the RGB color textures by the acquired target compression mode, adding noise to the RGB color textures with reduced number of color bits, and performing color smoothing on the RGB color textures with reduced number of color bits by the added noise.
Step 908, combining the compressed color texture with the Alpha channel texture to obtain a compressed texture image file for display on the mobile terminal.
It should be understood that, although the steps in the flowcharts of fig. 3-6 and 9 are shown in order as indicated by the arrows, these steps are not necessarily performed in order as indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps of fig. 3-6 and 9 may include multiple sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, nor does the order in which the sub-steps or stages are performed necessarily occur in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 10, there is provided a Unity 3D-based image compression apparatus, including: a file acquisition module 1011, an attribute information determination module 1012, a compression scheme acquisition module 1013, a separation module 1014, a compression module 1015, and a combination module 1016, wherein:
A file acquisition module 1011, configured to acquire a texture image file in Unity 3D;
the texture image file comprises at least one of a POT mapping file with an Alpha channel, a POT mapping file without an Alpha channel and an NPOT mapping file.
An attribute information determining module 1012 for determining attribute information of the texture image file;
a compression mode obtaining module 1013, configured to obtain a target compression mode adapted to the attribute information when the determined attribute information meets a preset condition;
a separation module 1014 for separating color textures and Alpha channel textures from the texture image file;
a compression module 1015, configured to compress the color texture according to the obtained target compression manner;
and a combining module 1016, configured to combine the compressed color texture with the Alpha channel texture to obtain a compressed texture image file for displaying on the mobile terminal.
In the above embodiment, by determining the attribute information of the texture image file, the target compression mode adapted to the attribute information is obtained, and the relationship between the compression mode and the texture image file is established, so that the adapted compression mode is selected in a targeted manner, and the image quality of the compressed texture image file is improved. The color textures in the texture image file are compressed in the acquired target compression mode, and the compressed color textures and Alpha channel textures are combined, so that the compression of the texture image is realized, and meanwhile, the generation of color gradation caused by the compressed Alpha channel textures is avoided, and the problem of distortion of the texture image file is avoided.
In one embodiment, the color textures comprise RGB color textures; the Alpha channel texture comprises a transparent channel texture;
the compression module 1015 is further configured to reduce a color bit number of the RGB color textures by using the obtained target compression manner; adding noise for RGB color textures after reducing color digits, wherein the added noise is used for performing color smoothing on the RGB color textures after reducing the color digits;
the combining module 1016 is further configured to combine the RGB color textures with the added noise with the transparent channel textures.
In the above embodiment, the number of color bits of the RGB color textures is reduced by the target compression method, and noise is added to the RGB color textures with reduced number of color bits, so that the compressed RGB color textures are smoothed, the problem of sharp textures between the compressed RGB color textures is avoided, and the display effect of the RGB color textures is improved.
In one embodiment, the compression mode obtaining module is further configured to obtain a resolution of a display screen and an operating system identifier of the mobile terminal; acquiring a target compression mode matched with the attribute information, the resolution of the display screen and the operating system identifier;
The compression module 1015 is further configured to compress the color texture scaled according to the resolution of the display screen in the target compression manner;
the combining module 1016 is further configured to combine the compressed color texture with the Alpha channel texture scaled by the display screen resolution.
In the above embodiment, by acquiring the resolution of the display screen and the operating system identifier of the mobile terminal and selecting the adaptive target compression mode according to the resolution of the display screen and the operating system identifier, the texture image file can be effectively compressed according to the selection of the appropriate target compression mode of different types of mobile terminals, so as to meet the display requirements of the mobile terminal and effectively improve the display effect of the texture image file.
In one embodiment, the attribute information includes a keyword of a file name of the texture image file; the target compression mode is a Dither565 compression mode;
the compression method obtaining module 1013 is further configured to detect a preset name suffix in the file name; the preset name suffix is used for identifying a texture image file adapting to the target compression mode; and when the preset name suffix is detected, acquiring a target compression mode matched with the preset name suffix.
In the above embodiment, by detecting the keywords of the file name of the texture image file, when the corresponding keywords are detected, the corresponding Dither565 compression mode is selected according to the detected keywords, so that the problem that the RGB 16bit is adopted to generate the color level in the traditional mode is avoided, and the display effect of the texture image file is improved.
For specific limitations of the Unity 3D-based image compression means, reference may be made to the above limitations of the XXX method, which are not repeated here. The above-described modules in the Unity 3D-based image compression means may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the steps of when executing the computer program:
acquiring a texture image file in Unity 3D; determining attribute information of the texture image file; when the determined attribute information meets a preset condition, acquiring a target compression mode matched with the attribute information; separating color textures and Alpha channel textures from the texture image file; compressing the color textures in the acquired target compression mode; and combining the compressed color textures with the Alpha channel textures to obtain compressed texture image files for display on the mobile terminal.
The texture image file comprises at least one of a POT mapping file with an Alpha channel, a POT mapping file without an Alpha channel and an NPOT mapping file.
In one embodiment, the processor when executing the computer program further performs the steps of:
the color textures include RGB color textures; the Alpha channel texture comprises a transparent channel texture;
reducing the color bit number of the RGB color textures by the acquired target compression mode; adding noise for RGB color textures after reducing color digits, wherein the added noise is used for performing color smoothing on the RGB color textures after reducing the color digits; the RGB color textures added with noise are combined with the transparent channel textures.
In one embodiment, the processor when executing the computer program further performs the steps of:
acquiring the resolution of a display screen and an operating system identifier of the mobile terminal; acquiring a target compression mode matched with the attribute information, the resolution of the display screen and the operating system identifier; compressing color textures scaled according to the resolution of the display screen in the target compression mode; and combining the compressed color textures with the Alpha channel textures scaled according to the resolution of the display screen.
In one embodiment, the processor when executing the computer program further performs the steps of:
the attribute information includes keywords of file names of the texture image files; the target compression mode is a Dither565 compression mode; detecting a preset name suffix in the file name; the preset name suffix is used for identifying a texture image file adapting to the target compression mode; and when the preset name suffix is detected, acquiring a target compression mode matched with the preset name suffix.
In one embodiment, a computer readable storage medium is provided having a computer program stored thereon, which when executed by a processor, performs the steps of:
acquiring a texture image file in Unity 3D; determining attribute information of the texture image file; when the determined attribute information meets a preset condition, acquiring a target compression mode matched with the attribute information; separating color textures and Alpha channel textures from the texture image file; compressing the color textures in the acquired target compression mode; and combining the compressed color textures with the Alpha channel textures to obtain compressed texture image files for display on the mobile terminal.
The texture image file comprises at least one of a POT mapping file with an Alpha channel, a POT mapping file without an Alpha channel and an NPOT mapping file.
In one embodiment, the computer program when executed by the processor further performs the steps of:
the color textures include RGB color textures; the Alpha channel texture comprises a transparent channel texture; reducing the color bit number of the RGB color textures by the acquired target compression mode; adding noise for RGB color textures after reducing color digits, wherein the added noise is used for performing color smoothing on the RGB color textures after reducing the color digits; the RGB color textures added with noise are combined with the transparent channel textures.
In one embodiment, the computer program when executed by the processor further performs the steps of:
acquiring the resolution of a display screen and an operating system identifier of the mobile terminal; acquiring a target compression mode matched with the attribute information, the resolution of the display screen and the operating system identifier; compressing color textures scaled according to the resolution of the display screen in the target compression mode; and combining the compressed color textures with the Alpha channel textures scaled according to the resolution of the display screen.
In one embodiment, the computer program when executed by the processor further performs the steps of:
the attribute information includes keywords of file names of the texture image files; the target compression mode is a Dither565 compression mode; detecting a preset name suffix in the file name; the preset name suffix is used for identifying a texture image file adapting to the target compression mode; and when the preset name suffix is detected, acquiring a target compression mode matched with the preset name suffix.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the various embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples merely represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the invention. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application is to be determined by the claims appended hereto.

Claims (10)

1. A Unity 3D-based image compression method, the method comprising:
acquiring a texture image file in Unity 3D;
determining attribute information of the texture image file; the attribute information is file name, file size or texture type;
when the determined attribute information meets preset conditions, acquiring the resolution of a display screen of the mobile terminal and an operating system identifier; acquiring a target compression mode matched with the attribute information, the resolution of the display screen and the operating system identifier;
Separating color textures and Alpha channel textures from the texture image file;
compressing the color textures scaled according to the resolution of the display screen in the target compression mode;
combining the compressed color textures with the Alpha channel textures scaled according to the resolution of the display screen to obtain compressed texture image files for display on the mobile terminal;
the obtaining the target compression mode adapted to the attribute information, the display screen resolution and the operating system identifier includes:
when the attribute information is a file name, judging whether the file name meets a preset keyword, if so, acquiring a target compression mode matched with the file name, the resolution of the display screen and the identification of the operating system;
when the attribute information is the file size, judging whether the file size is larger than a preset file size threshold value, if so, acquiring a target compression mode corresponding to the file size, the display screen resolution and the operating system identifier;
and when the attribute information is the texture type, judging whether the texture type meets the preset texture type, and if so, acquiring a target compression mode corresponding to the texture type, the resolution of the display screen and the identification of the operating system.
2. The method of claim 1, wherein the color textures comprise RGB color textures; the Alpha channel texture comprises a transparent channel texture;
the compressing the color textures scaled according to the resolution of the display screen in the target compression mode comprises the following steps:
reducing the color bit number of the RGB color textures by the acquired target compression mode;
adding noise for RGB color textures after reducing color digits, wherein the added noise is used for performing color smoothing on the RGB color textures after reducing the color digits;
the combining the compressed color textures with the Alpha channel textures scaled by the resolution of the display screen comprises:
the RGB color textures added with noise are combined with the transparent channel textures.
3. The method of claim 1, wherein the Alpha channel texture is an opaque or translucent channel texture.
4. The method according to claim 1, wherein the attribute information includes a keyword of a file name of the texture image file; the target compression mode is a Dither565 compression mode;
and when the determined attribute information meets a preset condition, acquiring a target compression mode matched with the attribute information, wherein the method comprises the following steps:
Detecting a preset name suffix in the file name; the preset name suffix is used for identifying a texture image file adapting to the target compression mode;
and when the preset name suffix is detected, acquiring a target compression mode matched with the preset name suffix.
5. The method of any one of claims 1 to 4, wherein the texture image file comprises at least one of a POT map file with Alpha channels, a POT map file without Alpha channels, and an NPOT map file.
6. An image compression apparatus based on Unity3D, the apparatus comprising:
the file acquisition module is used for acquiring texture image files in the Unity 3D;
the attribute information determining module is used for determining attribute information of the texture image file; the attribute information is file name, file size or texture type;
the compression mode acquisition module is used for acquiring the resolution of a display screen and an operating system identifier of the mobile terminal when the determined attribute information meets preset conditions; acquiring a target compression mode matched with the attribute information, the resolution of the display screen and the operating system identifier;
the separation module is used for separating color textures and Alpha channel textures from the texture image file;
The compression module is used for compressing the color textures scaled according to the resolution of the display screen in the target compression mode;
the combination module is used for combining the compressed color textures with the Alpha channel textures scaled according to the resolution of the display screen to obtain compressed texture image files for display on the mobile terminal;
the obtaining the target compression mode adapted to the attribute information, the display screen resolution and the operating system identifier includes:
when the attribute information is a file name, judging whether the file name meets a preset keyword, if so, acquiring a target compression mode matched with the file name, the resolution of the display screen and the identification of the operating system;
when the attribute information is the file size, judging whether the file size is larger than a preset file size threshold value, if so, acquiring a target compression mode corresponding to the file size, the display screen resolution and the operating system identifier;
and when the attribute information is the texture type, judging whether the texture type meets the preset texture type, and if so, acquiring a target compression mode corresponding to the texture type, the resolution of the display screen and the identification of the operating system.
7. The apparatus of claim 6, wherein the color textures comprise RGB color textures; the Alpha channel texture comprises a transparent channel texture;
the compression module is also used for reducing the color bit number of the RGB color textures through the acquired target compression mode; adding noise for RGB color textures after reducing color digits, wherein the added noise is used for performing color smoothing on the RGB color textures after reducing the color digits;
the combination module is further configured to combine the RGB color textures with noise added with the transparent channel textures.
8. The apparatus of claim 6, wherein the compressed mode obtaining module is further configured to obtain a display resolution and an operating system identifier of the mobile terminal; acquiring a target compression mode matched with the attribute information, the resolution of the display screen and the operating system identifier;
the compression module is also used for compressing color textures scaled according to the resolution of the display screen in the target compression mode;
the combination module is further configured to combine the compressed color texture with the Alpha channel texture scaled according to the resolution of the display screen.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 5 when the computer program is executed.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 5.
CN201810153558.1A 2018-02-22 2018-02-22 Image compression method, device, computer equipment and storage medium based on Unity3D Active CN110189384B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810153558.1A CN110189384B (en) 2018-02-22 2018-02-22 Image compression method, device, computer equipment and storage medium based on Unity3D

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810153558.1A CN110189384B (en) 2018-02-22 2018-02-22 Image compression method, device, computer equipment and storage medium based on Unity3D

Publications (2)

Publication Number Publication Date
CN110189384A CN110189384A (en) 2019-08-30
CN110189384B true CN110189384B (en) 2023-12-26

Family

ID=67704602

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810153558.1A Active CN110189384B (en) 2018-02-22 2018-02-22 Image compression method, device, computer equipment and storage medium based on Unity3D

Country Status (1)

Country Link
CN (1) CN110189384B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112507444B (en) * 2021-02-03 2021-05-07 四川见山科技有限责任公司 AI-construction-based digital urban building night scene generation method and system
CN113706640A (en) * 2021-08-05 2021-11-26 网易(杭州)网络有限公司 Method, device, storage medium and electronic equipment for compressing image
CN113628292B (en) * 2021-08-16 2023-07-25 上海云轴信息科技有限公司 Method and device for previewing pictures in target terminal
CN117408907B (en) * 2023-12-15 2024-03-22 齐鲁空天信息研究院 Method and device for improving image countermeasure capability and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05161018A (en) * 1991-12-06 1993-06-25 Dainippon Screen Mfg Co Ltd Picture transmission system
CN102289829A (en) * 2011-07-12 2011-12-21 北京朗玛数联科技有限公司 Method and device for storing and restoring image and system for processing image
CN106204672A (en) * 2016-08-03 2016-12-07 深圳市创梦天地科技有限公司 Texture compression document generating method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05161018A (en) * 1991-12-06 1993-06-25 Dainippon Screen Mfg Co Ltd Picture transmission system
CN102289829A (en) * 2011-07-12 2011-12-21 北京朗玛数联科技有限公司 Method and device for storing and restoring image and system for processing image
CN106204672A (en) * 2016-08-03 2016-12-07 深圳市创梦天地科技有限公司 Texture compression document generating method

Also Published As

Publication number Publication date
CN110189384A (en) 2019-08-30

Similar Documents

Publication Publication Date Title
CN110189384B (en) Image compression method, device, computer equipment and storage medium based on Unity3D
US10970804B2 (en) Image processing device and image processing method for selecting regions based on gradiation for embedding a watermark
CA3154893C (en) Image color transferring method, device, computer equipment and storage medium
CN110139104B (en) Video decoding method, video decoding device, computer equipment and storage medium
US10853917B2 (en) Color image authentication method based on palette compression technique
CN112581477A (en) Image processing method, image matching method, device and storage medium
CN114418825B (en) Image processing method, image processing device, computer equipment and storage medium
EP3410686B1 (en) Image processing device, image processing method, and program
CN105261044A (en) Similar picture identification method and device and electronic equipment
US10706489B2 (en) Image processing device, image processing method, and program for generating water marks
US10049425B2 (en) Merging filters for a graphic processing unit
CN111064986B (en) Animation data sending method with transparency, animation data playing method and computer equipment
CN113516739A (en) Animation processing method and device, storage medium and electronic equipment
CN110730277A (en) Information coding and method and device for acquiring coded information
CN108388463A (en) Icon processing method, device, computer equipment and storage medium
CN113516738B (en) Animation processing method and device, storage medium and electronic equipment
CN114067004A (en) Image processing method, image processing device, computer equipment and storage medium
CN105900413A (en) Image processing program, display program, image processing method, display method, image processing device, and information processing device
JP6482452B2 (en) Screen transition identification device, screen transition identification system, and screen transition identification method
CN116977154B (en) Visible light image and infrared image fusion storage method, device, equipment and medium
CN111597773B (en) Compression processing method, compression processing device, computer storage medium and terminal
CN115937338B (en) Image processing method, device, equipment and medium
CN115205358A (en) Method for adding skin texture in image, and method and device for processing human face image
CN117201699A (en) Image data processing method, device, electronic equipment and storage medium
CN114758339A (en) Method and device for acquiring character recognition model, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant