Screenshot processing method and device

文档序号:1875109 发布日期:2021-11-23 浏览:13次 中文

阅读说明:本技术 一种截图处理方法及装置 (Screenshot processing method and device ) 是由 李娜芬 李斌 梁百怡 于 2020-05-08 设计创作,主要内容包括:本发明提供了一种截图处理方法、装置、电子设备及计算机可读存储介质;方法包括:应用程序的第一进程创建用于截图的第二进程;第二进程获取目标显示器的扫描密度;其中,目标显示器为需要被截图的显示器;第二进程获取目标显示器的桌面图片,并根据目标显示器的扫描密度确定桌面图片的物理尺寸;第二进程创建符合物理尺寸的截图窗口,并在截图窗口中显示桌面图片;第二进程根据截图窗口中的桌面图片生成截图结果。通过本发明,能够实现精确截图。(The invention provides a screenshot processing method, a screenshot processing device, electronic equipment and a computer-readable storage medium; the method comprises the following steps: a first process of an application program creates a second process for screenshot; the second process obtains the scanning density of the target display; the target display is a display which needs to be subjected to screenshot; the second process acquires a desktop picture of the target display and determines the physical size of the desktop picture according to the scanning density of the target display; a second process creates a screenshot window conforming to the physical size and displays a desktop picture in the screenshot window; and the second process generates a screenshot result according to the desktop picture in the screenshot window. By the method and the device, accurate screenshot can be realized.)

1. A screenshot processing method, the method comprising:

a first process of an application program creates a second process for screenshot;

the second process obtains the scanning density of the target display; the target display is a display needing to be subjected to screenshot;

the second process acquires a desktop picture of the target display and determines the physical size of the desktop picture according to the scanning density of the target display;

the second process creates a screenshot window conforming to the physical size and displays the desktop picture in the screenshot window;

and the second process generates a screenshot result according to the desktop picture in the screenshot window.

2. The method of claim 1, the first process of the application creating a second process for screenshot comprising:

when the first process of the application program is a main process of the application program and the first process is started, the first process creates the second process, or when the first process receives a screenshot instruction sent by an operating system, the first process creates the second process;

the first process sends the path parameters of the codes of the screenshot window to the second process;

and the path parameter is used for enabling the second process to read the code of the screenshot window according to the path parameter and to create the screenshot window conforming to the physical size when the physical size is obtained.

3. The method of claim 1, wherein the second process obtaining the scan density of the target display comprises:

the second process declares to an operating system that a scan density perception mode of the second process is display-level perception to query the operating system for scan density of the target display.

4. The method of claim 1, wherein the second process obtains a desktop image of the target display, comprising:

the second process calls a screenshot interface of the operating system to

Acquiring a desktop picture matched with the identification of the target display and the screenshot time from the screenshot interface;

the determining the physical size of the screenshot window according to the scan density of the target display comprises:

determining the ratio of the pixel width of the desktop picture to the scanning density of the target display as the physical width of the desktop picture in the target display, and

and determining the ratio of the pixel height of the desktop picture to the scanning density of the target display as the physical height of the desktop picture in the target display.

5. The method of claim 4, wherein the second process creates a screenshot window that fits the physical size, comprising:

and the second process creates a screenshot window conforming to the physical width and the physical height in the target display according to the physical width and the physical height of the desktop picture in the target display.

6. The method of claim 1, wherein when in an extended mode, the target display comprises a main display and a secondary display; the displaying the desktop picture in the screenshot window includes:

and displaying the desktop picture of the main display in the partial screenshot window created by the main display, and displaying the desktop picture of the auxiliary display in the partial screenshot window created by the auxiliary display.

7. The method of claim 1, further comprising:

the first process obtains effect data of the screenshot, serializes the effect data into a byte sequence, and

sending the byte sequence to the second process;

the second process generates screenshot results based on the desktop pictures in the screenshot window, including:

the second process deserializes the byte sequence to obtain the effect data;

displaying an additive special effect in a toolbar of the screenshot window according to the effect data;

and responding to the special effect editing operation of the desktop picture based on the special effect, fusing the desktop picture and special effect data generated according to the special effect editing operation to obtain a screenshot result.

8. The method of claim 7, wherein after displaying the desktop image in the screenshot window, the method further comprises:

the second process responds to the screenshot area selection operation and obtains the position parameters of the screenshot area;

displaying the position of the screenshot area in the screenshot window according to the position parameter of the screenshot area;

the fusing the desktop picture with the special effect data generated according to the special effect editing operation includes:

performing cutout processing on the desktop picture according to the position parameter of the screenshot area;

and fusing the picture of the screenshot area obtained after the matting processing with special effect data generated according to the special effect editing operation.

9. The method of any of claims 1 to 8, wherein after the second process generates screenshot results from the desktop pictures in the screenshot window, the method further comprises:

the second process sends the screenshot result to a data sharing position of an operating system and informs the first process of finishing screenshot so as to enable the screenshot

The first process ends the second process.

10. A screenshot processing apparatus, comprising:

the creation module is used for creating a second process for screenshot by a first process of the application program;

the acquisition module is used for acquiring the scanning density of the target display in the second process; the target display is a display needing to be subjected to screenshot;

the determining module is used for acquiring the desktop picture of the target display in the second process and determining the physical size of the desktop picture according to the scanning density of the target display;

the display module is used for creating a screenshot window conforming to the physical size by the second process and displaying the desktop picture in the screenshot window;

and the screenshot generating module is used for the second process to generate a screenshot result according to the desktop picture in the screenshot window.

Technical Field

The present invention relates to image processing technologies, and in particular, to a screenshot processing method and apparatus, an electronic device, and a computer-readable storage medium.

Background

With the popularization of computer equipment, more and more users select to connect a plurality of displays to the notebook computer for work or entertainment, so that different display screens can be used for displaying different work contents, the window switching times are reduced, and the work efficiency is improved. However, when the scanning densities of the connected displays are different, the entire desktop image may be too large or too small if the screenshot operation is performed on the non-main display. The user can not obtain the expected screenshot result, so that the use experience of the screenshot is influenced.

Disclosure of Invention

The embodiment of the invention provides a screenshot processing method and device, electronic equipment and a computer-readable storage medium, which can realize accurate screenshot.

The technical scheme of the embodiment of the invention is realized as follows:

the embodiment of the invention provides a screenshot processing method, which comprises the following steps:

a first process of an application program creates a second process for screenshot;

the second process obtains the scanning density of the target display; the target display is a display needing to be subjected to screenshot;

the second process acquires a desktop picture of the target display and determines the physical size of the desktop picture according to the scanning density of the target display;

the second process creates a screenshot window conforming to the physical size and displays the desktop picture in the screenshot window;

and the second process generates a screenshot result according to the desktop picture in the screenshot window.

An embodiment of the present invention provides a screenshot processing apparatus, including:

the creation module is used for creating a second process for screenshot by a first process of the application program;

the acquisition module is used for acquiring the scanning density of the target display in the second process; the target display is a display needing to be subjected to screenshot;

the determining module is used for acquiring the desktop picture of the target display in the second process and determining the physical size of the desktop picture according to the scanning density of the target display;

the display module is used for creating a screenshot window conforming to the physical size by the second process and displaying the desktop picture in the screenshot window;

and the screenshot generating module is used for the second process to generate a screenshot result according to the desktop picture in the screenshot window.

In the foregoing solution, the creating module is configured to:

when the first process of the application program is a main process of the application program and the first process is started, the first process creates the second process, or when the first process receives a screenshot instruction sent by an operating system, the first process creates the second process;

the first process sends the path parameters of the codes of the screenshot window to the second process;

and the path parameter is used for enabling the second process to read the code of the screenshot window according to the path parameter and to create the screenshot window conforming to the physical size when the physical size is obtained.

The obtaining module is configured to:

the second process declares to an operating system that a scan density perception mode of the second process is display-level perception to query the operating system for scan density of the target display.

The determining module is configured to:

the second process calls a screenshot interface of the operating system to

Acquiring a desktop picture matched with the identification of the target display and the screenshot time from the screenshot interface;

determining the ratio of the pixel width of the desktop picture to the scanning density of the target display as the physical width of the desktop picture in the target display, and

and determining the ratio of the pixel height of the desktop picture to the scanning density of the target display as the physical height of the desktop picture in the target display.

The display module is used for:

and the second process creates a screenshot window conforming to the physical width and the physical height in the target display according to the physical width and the physical height of the desktop picture in the target display.

The display module is further configured to:

when in an extended mode, the target display comprises a primary display and a secondary display; and displaying the desktop picture of the main display in the partial screenshot window created by the main display, and displaying the desktop picture of the auxiliary display in the partial screenshot window created by the auxiliary display.

The screenshot generating module is configured to:

the first process obtains effect data of the screenshot, serializes the effect data into a byte sequence, and

sending the byte sequence to the second process;

the second process deserializes the byte sequence to obtain the effect data;

displaying an additive special effect in a toolbar of the screenshot window according to the effect data;

and responding to the special effect editing operation of the desktop picture based on the special effect, fusing the desktop picture and special effect data generated according to the special effect editing operation to obtain a screenshot result.

The screenshot generating module is further configured to:

the second process responds to the screenshot area selection operation and obtains the position parameters of the screenshot area;

and displaying the position of the screenshot area in the screenshot window according to the position parameter of the screenshot area.

The screenshot generating module is further configured to:

performing cutout processing on the desktop picture according to the position parameter of the screenshot area;

and fusing the picture of the screenshot area obtained after the matting processing with special effect data generated according to the special effect editing operation.

The screenshot generating module is further configured to:

the second process sends the screenshot result to a data sharing position of an operating system and informs the first process of finishing screenshot so as to enable the screenshot

The first process ends the second process.

An embodiment of the present invention further provides an electronic device, including:

a memory for storing executable instructions;

and the processor is used for realizing the screenshot processing method provided by the embodiment of the invention when the executable instruction stored in the memory is executed.

The embodiment of the invention also provides a computer-readable storage medium, which stores executable instructions and is used for causing a processor to execute the screenshot processing method provided by the embodiment of the invention.

The embodiment of the invention has the following beneficial effects:

the second process is established by the first process for screenshot processing, and since the screenshot processing is decoupled from the first process, the workload of the first process can be reduced, and the stable operation of the first process is ensured; and in the second process, the screenshot window is created according to the scanning density of the target display, so that the physical size of the screenshot window can be adapted to the target display, and the accuracy of the screenshot result generated based on the screenshot window is further ensured.

Drawings

FIG. 1A is a diagram of a related art screenshot of an extension in the case where the scan density of the secondary display is less than the scan density of the primary display;

FIG. 1B is a diagram of a related art screenshot of a secondary display in the case where the scan density of the secondary display is less than the scan density of the primary display;

FIG. 1C is a diagram of a related art screenshot of a secondary display in the case where the scan density of the secondary display is greater than the scan density of the primary display;

FIG. 2 is a schematic structural diagram of an electronic device according to an embodiment of the present invention;

fig. 3A is a schematic flowchart of a screenshot processing method according to an embodiment of the present invention;

fig. 3B is a flowchart illustrating a screenshot processing method according to an embodiment of the present invention;

FIG. 4A is a diagram of a screenshot window provided by an embodiment of the present invention;

FIG. 4B is a diagram of a screenshot window provided by an embodiment of the present invention;

FIG. 5 is a flowchart illustrating a screenshot processing method according to an embodiment of the present invention;

FIG. 6 is a flow diagram of a screenshot provided by an embodiment of the present invention;

fig. 7 is a schematic diagram of a screenshot of a session window in an application program according to an embodiment of the present invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail with reference to the accompanying drawings, the described embodiments should not be construed as limiting the present invention, and all other embodiments obtained by a person of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict.

Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to be limiting of the invention.

Before further detailed description of the embodiments of the present invention, terms and expressions mentioned in the embodiments of the present invention are explained, and the terms and expressions mentioned in the embodiments of the present invention are applied to the following explanations.

1) The scanning density is in Dots Per Inch (DPI) and is used to represent the number of dots in one inch length of a display screen in the embodiment of the present invention, and each Dot is used to display one pixel point. For example, 96DPI indicates 96 dots per inch of length of the display and 120DPI indicates 120 dots per inch of length of the display. DPI can be used to control the physical size of an object (e.g., text, image) displayed by a screen, with the display resolution of the display screen fixed, the larger the DPI, the larger the physical size of the object in the screen.

2) Scan density aware mode, the operating system supports techniques for applications to read the scan density of a screen of a display. Taking the Windows system as an example, the support for scan density includes the following levels:

not sensing, forcibly zooming the interface of the application program by an operating system, and blurring the interface;

system level sensing, the display size of the interface of the application program is not controlled by an operating system, only when the scanning density is changed, the operating system performs forced zooming on the interface of the application program through DWM (Desktop Window Manager) virtualization, and the interface is fuzzy;

display level perception: when the multiple displays are expanded to display, the application program can sense the scanning density of each display and display normally.

3) Single screen mode, a mode in which the electronic device displays content using only one display.

4) Multi-screen mode, a mode in which an electronic device cooperatively displays using a plurality of (at least two) displays (simply referred to as physical displays/screens). The display that outputs the image frame is a main display by default, and the display that copies or expands the display content of the main display is called a sub-display. Wherein the types of the multi-screen mode include:

4.1) a copy mode, namely copying the content in the main display to the display of the secondary display, wherein the resolution of the main display and the secondary display is the same;

4.2) an expansion mode, namely, the main display and the sub-display are virtualized into a virtual display with a larger area so as to spatially extend the display space of the main display, and the main display and the sub-display can display different contents. For example, the main display displays the document contents and the sub-display plays the video. A main display and a sub display may be provided. For example, when the notebook computer is externally connected with the display, the operating system of the notebook computer supports the user to set the built-in display of the notebook computer as the main display, and also supports the user to set the externally connected display as the main display.

5) And a screenshot interface, wherein the operating system opens an interface for the application program, and the interface can output a screen picture.

6) The desktop environment, referred to as a desktop for short, is an area where an electronic device (e.g., a computer) displays content on a display screen after successfully logging in an operating system. For example, in the initial state of the desktop, which is exemplified by a Windows (Windows) system, the desktop includes the following elements: a taskbar, an application icon, and a start button (for access to programs, folders, and computer settings); in the usage state of the desktop, the desktop includes various contents such as web pages, documents, videos, and the like, so that various elements of the initial state may be partially or completely occluded.

7) The Main Process (Main Process), the parent Process from which the application program is first started, is an entry for executing the application program, and may be a Process for executing a Main () function, for example.

Screenshots are very common operations on personal computers that can generate a still picture from a portion or all of the display presentation. With the popularity of notebook computers today, more and more users are working and entertaining with a convenient notebook computer having a small display coupled to a desktop large display. If the two displays connected have different scan densities, the scan density perception mode of the application requiring the screenshot is display level sensitive. Due to the huge workload, the applications compatible with the old version Windows system in the related art do not realize the display level sensitivity of scan density.

Specifically, the application does not use a new screenshot process, but directly performs the screenshot in the main process of the application. In this case, the scanning density perception mode of the screenshot function is consistent with that of the main process, if the main process does not support display-level perception, accurate screenshot of the screen cannot be realized, and the screenshot of a non-main display (a secondary display) has the phenomenon that the desktop display area is larger (incomplete) or smaller than the display screen; if the host process supports display-level sensing, the workload of the host process will be greatly increased.

As shown in fig. 1A, fig. 1A is a schematic diagram of a related art screenshot of an extended screen in a case where the scan density of the sub-display is smaller than that of the main display. If the scan density perception mode of the screenshot in the main process is set as system level perception and the scan density of the secondary display is smaller than that of the main display, when the screenshot is performed, the desktop picture 110 of the main display and the desktop picture 120 of the secondary display are drawn into the canvas (set as the scan density of the main display) of the screenshot window of the extended screen composed of the main display and the secondary display, because the canvas of the screenshot window is adapted to the scan density of the main display, in the case that the scan density (e.g. 200DPI) of the main display is greater than that (e.g. 100DPI) of the secondary display, the desktop picture in the main display will be displayed in a normal size, the desktop picture in the secondary display will be too small, and a black margin will appear in the screenshot result 130.

As shown in fig. 1B, fig. 1B is a schematic diagram of a related art screenshot of a sub-display in a case where the scan density of the sub-display is smaller than that of a main display. If the screen perception mode of the screenshot in the main process is set as system level perception and the scan density of the secondary display is less than that of the main display, then when the screenshot is taken for the secondary display, the desktop picture 150 of the secondary display is too small and a black border appears in the screenshot result 140.

As shown in fig. 1C, fig. 1C is a schematic diagram of a related art screenshot of a sub-display in a case where the scan density of the sub-display is greater than that of a main display. If the screen perception mode of the screenshot in the main process is set as system level perception and the scan density of the secondary display is greater than that of the main display, then when the screenshot is taken for the secondary display, the desktop picture 170 of the secondary display is too large to be displayed completely on the screen in the screenshot result 160.

When the type of the multi-screen mode is a copy mode, the resolution of the main display and the sub display are the same, if the physical sizes of the main display and the sub display are the same, the scanning densities of the main display and the sub display are the same, and the phenomenon that the desktop of the sub display is too large or too small cannot occur in screenshot. If the physical sizes of the main display and the auxiliary display are different, the phenomenon that the desktop of the auxiliary display is too large or too small can occur during screenshot.

It can be seen that the related art cannot support display-level sensing, and therefore, when the scan densities of the main display and the sub display are different, the screenshot cannot be correctly displayed in the sub display, and accurate screenshot cannot be realized.

Based on this, embodiments of the present invention provide a screenshot processing method and apparatus, an electronic device, and a computer-readable storage medium, which can implement accurate screenshot when scan densities of a primary display and a secondary display are different. The electronic device provided by the embodiment of the invention can be implemented as various types of user terminals such as a notebook computer, a tablet computer, a desktop computer, a set-top box, a mobile device (e.g., a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, and a portable game device). In the following, exemplary applications of the electronic device will be explained.

Referring to fig. 2, fig. 2 is a schematic structural diagram of an electronic device 200 according to an embodiment of the present invention, where the electronic device 200 shown in fig. 2 includes: at least one processor 210, memory 250, at least one network interface 220, and a user interface 230. The various components in electronic device 200 are coupled together by a bus system 240. It is understood that the bus system 240 is used to enable communications among the components. The bus system 240 includes a power bus, a control bus, and a status signal bus in addition to a data bus. For clarity of illustration, the various buses are labeled as bus system 240 in FIG. 2.

The Processor 210 may be an integrated circuit chip having Signal processing capabilities, such as a general purpose Processor, a Digital Signal Processor (DSP), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like, wherein the general purpose Processor may be a microprocessor or any conventional Processor, or the like.

The user interface 230 includes one or more output devices 231, including one or more speakers and/or one or more visual display screens, that enable the presentation of media content. The user interface 230 also includes one or more input devices 232, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.

The memory 250 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid state memory, hard disk drives, optical disk drives, and the like. Memory 250 optionally includes one or more storage devices physically located remotely from processor 210.

The memory 250 includes volatile memory or nonvolatile memory, and may include both volatile and nonvolatile memory. The non-volatile memory may be a read-only memory and the volatile memory may be a random access memory. The memory 250 described in embodiments of the invention is intended to comprise any suitable type of memory.

In some embodiments, memory 250 is capable of storing data, examples of which include programs, modules, and data structures, or a subset or superset thereof, to support various operations, as exemplified below.

The operating system 251, which includes system programs for handling various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., is used for implementing various basic services and for processing hardware-based tasks.

A network communication module 252 for communicating to other computing devices via one or more (wired or wireless) network interfaces 220, exemplary network interfaces 220 including: bluetooth, wireless compatibility authentication (WiFi), and universal serial bus, among others.

A presentation module 253 for enabling presentation of information (e.g., a user interface for operating peripherals and displaying content and information) via one or more output devices 231 (e.g., a display screen, speakers, etc.) associated with the user interface 230.

An input processing module 254 for detecting one or more user inputs or interactions from one of the one or more input devices 232 and translating the detected inputs or interactions.

In some embodiments, the screenshot processing apparatus provided in the embodiments of the present invention may be implemented in software, and fig. 2 illustrates a screenshot processing apparatus 255 stored in the memory 250, which may be software in the form of programs and plug-ins, and includes the following software units: a creation module 2551, an acquisition module 2552, a determination module 2553, a display module 2554, a screenshot generation module 2555, which are logical and therefore can be arbitrarily combined or further split depending on the functionality implemented. The functions of the respective modules will be explained below.

In other embodiments, the apparatus provided in the embodiments of the present invention may be implemented in hardware, and for example, the apparatus provided in the embodiments of the present invention may be a processor in the form of a hardware decoding processor, which is programmed to execute the screenshot processing method provided in the embodiments of the present invention, for example, the processor in the form of the hardware decoding processor may be one or more Application Specific Integrated Circuits (ASICs), DSPs, Programmable Logic Devices (PLDs), Complex Programmable Logic Devices (CPLDs), Field Programmable Gate Arrays (FPGAs), or other electronic components.

The screenshot processing method provided by the embodiment of the present invention will be described in conjunction with exemplary applications and implementations of the electronic device provided by the embodiment of the present invention.

Referring to fig. 3A, fig. 3A is a schematic flowchart of a screenshot processing method according to an embodiment of the present invention, which will be described with reference to the steps shown in fig. 3A.

In step 101, a first process of an application running in an electronic device creates a second process for screenshot.

The application programs run in the electronic device include a social network application program, a shopping application program, a multimedia playing application program and the like. The first process of the application program is an entry for executing the application program, and may be a main process of the application program, such as a process for running a main function of the application program; or a sub-process created by the main process, such as a daemon process dedicated to listening for instructions transferred by the operating system and distributing the instructions. The second process is a sub-process created by the first process and used for executing operations related to screenshot.

In some embodiments, when a first process of an application program is a main process of the application program, and the first process is started, the first process creates a second process, or when the first process receives a screenshot instruction sent by an operating system, the first process creates the second process; after a second process is created by the first process, the path parameter of the code of the screenshot window is sent to the second process; and the second process can read the code of the screenshot window according to the path parameters and create the screenshot window conforming to the physical size when the physical size of the desktop picture is obtained.

The screenshot instruction can be generated after the user performs screenshot operation, or can be generated when the operating system executes a planning task. And after receiving the screenshot operation implemented by the user, the operating system generates a screenshot instruction and transmits the screenshot instruction to the first process so as to trigger the first process to create a second process. Parameters of the screenshot instruction include: time of screenshot, display that needs screenshot (main display/sub-display/main display and sub-display); parameters of the screenshot instruction may include: location of the screenshot area, screenshot effect, etc. The scheduling task is used to instruct the operating system to take a screenshot regularly or irregularly and store the screenshot as a log. For example, in an office scene, the log may be used to perform dangerous operation analysis, further determine whether a data leakage risk exists, and trigger an alarm.

In step 102, a second process of the application program obtains a scan density of the target display.

Wherein, the target display is a display which needs to be captured. During screenshot, if the electronic equipment is in a single-screen mode, the target display and the main display are the same display; and if the target display is in a multi-screen mode, the target display is a main display and a secondary display.

In the code development stage of the application program, the scanning density perception mode of the second process is declared to be display-level perception in the screenshot project used by the second process, so after the second process is created, the second process can inquire the operating system about the scanning density of the target display. As an example, the scan density of the display may be obtained through a GetDpiForMonitor interface. When the target displays are multiple, the second process simultaneously acquires the scanning density of the multiple target displays.

In step 103, the second process of the application program obtains a desktop image of the target display.

In one possible example, the second process calls a screenshot interface opened to the application program by the operating system, interface parameter screenshot time and the identification of the target display, and acquires a desktop picture matched with the identification of the target display and the screenshot time from the screenshot interface through the interface parameters. After the desktop picture is obtained, the second process further obtains the pixel width (the number of pixels in the horizontal direction) and the pixel height (the number of pixels in the vertical direction) of the desktop picture, and stores the desktop picture in the memory.

When in an expansion mode cooperatively displayed by the main display and the at least one sub-display, the target display is the main display and the at least one sub-display; at this time, the second process simultaneously acquires the desktop picture of the main display and the desktop picture of the auxiliary display.

When the target display is the auxiliary display, the second process acquires a desktop picture of the auxiliary display; and when the target display is the main display, the second process acquires the desktop picture of the main display.

In step 104, the second process of the application determines the physical size of the desktop image based on the scan density of the target display.

In one possible example, the physical dimensions of the desktop image include a physical width and a physical height of the desktop image in inches in the target display. And after the desktop picture is obtained in the second process, determining the ratio of the pixel width of the desktop picture to the scanning density of the target display as the physical width of the desktop picture in the target display, and determining the ratio of the pixel height of the desktop picture to the scanning density of the target display as the physical height of the desktop picture in the target display.

For example, the pixel width and the pixel height of the desktop image are 1920 pixels and 1080 pixels respectively, and the scan density of the target display is 120DPI, then the physical width is 16 inches and the physical height is 9 inches. When in the extended mode, the second process determines the physical dimensions of the desktop images of the main display and the sub-display according to the scan densities of the main display and the sub-display, respectively.

In step 105, the second process of the application creates a screenshot window that conforms to the physical dimensions.

In one possible example, the second process creates a screenshot window in the target display that conforms to the physical width and physical height of the desktop image based on the physical width and physical height of the desktop image in the main display.

When in the extended mode, the second process creates a partial screenshot window in the main display that conforms to the physical width and the physical height in the main display; according to the physical width and the physical height of the desktop picture in the auxiliary display, a partial screenshot window conforming to the physical width and the physical height in the auxiliary display is created in the auxiliary display in the second process; partial screenshot windows of the main display and the secondary display are combined into a complete screenshot window.

Referring to fig. 4A and 4B, fig. 4A and 4B are schematic diagrams of screenshot windows provided by an embodiment of the present invention. When the sizes of the main display and the sub-display are the same, for example, the displays are both 21.5 inches, as shown in fig. 4A, a screenshot window 1 is created in the main display on the left side, and the physical size of the screenshot window 1 is the same as the physical size of the desktop picture of the main display obtained in step 104; creating a screenshot window 2 in the secondary display on the right side, wherein the physical size of the screenshot window 2 is the same as that of the desktop picture of the secondary display obtained in the step 104; and splicing the screenshot window 1 and the screenshot window 2 to obtain a complete screenshot window.

When the main display and the sub-display are different in size, as shown by a dotted line in fig. 4B, the screenshot window is a rectangle surrounding the main display 3 and the sub-display 4, where the main display 3 and the sub-display 4 are effective display areas, and a part of the screenshot window below the main display 3 has no display content.

In step 106, the application displays the desktop picture in the screenshot window.

In one possible example, when in the extended mode, the target display includes a primary display and a secondary display; and displaying the desktop picture of the main display in the partial screenshot window created by the main display, and displaying the desktop picture of the auxiliary display in the partial screenshot window created by the auxiliary display. When the sizes of the main display and the sub display are the same, the desktop image of the main display is displayed in the screenshot window 1 according to the physical size obtained in step 104, and the desktop image of the sub display is displayed in the screenshot window 2 according to the physical size obtained in step 104. When the sizes of the main display and the sub-display are different, the desktop image of the main display is displayed on the main display 3 in accordance with the physical size obtained in step 104, and the desktop image of the sub-display is displayed on the sub-display 4 in accordance with the physical size obtained in step 104.

In step 107, the second process of the application generates a screenshot result from the desktop image in the screenshot window.

In one possible example, prior to step 107, the first process takes the effect data of the screenshot, serializes the effect data into a byte sequence, and sends the byte sequence to the second process. The serialization refers to a process of converting an object into a byte sequence, and the deserialization refers to a process of recovering the byte sequence into the object; serialization converts objects into an ordered byte stream for transmission over a network or for saving objects in a local file, ensuring the integrity and transferability of the objects. The effect data may be preset or set when the user triggers the screenshot operation, and include related data such as an invisible watermark (including identity information), characters, a mosaic and the like.

In a possible example, as shown in fig. 5, fig. 5 is a flowchart of a screenshot processing method provided in an embodiment of the present invention, and step 107 will be described with reference to the steps shown in fig. 5.

In step 201, the second process deserializes the byte sequence, resulting in effect data.

In step 202, the second process displays effects that can be added in a toolbar of the screenshot window according to the effect data.

In step 203, the second process, in response to the special effect editing operation on the desktop picture based on the special effect, fuses the desktop picture and the special effect data generated according to the special effect editing operation, and obtains a screenshot result.

If the identity information of the login user needs to be implanted into the effect data, the second process cannot acquire the identity information, so that the mode of transmitting the serialized effect data from the first process to the second process can be only adopted; if the effect data does not include the identity information of the user, the step of "the first process acquires the effect data of the screenshot, serializes the effect data into a byte sequence, and sends the byte sequence to the second process" may be omitted, and correspondingly, step 201 may also be omitted. A second process displays a toolbar in the created screenshot window, displays a plurality of special effects which can be added in the toolbar, supports a user to carry out special effect editing operation on the desktop picture by using the toolbar to generate special effect data, and fuses the special effect data with the desktop picture; when the user does not use the toolbar to carry out special effect editing operation on the desktop picture, no special effect data is generated, and fusion of the special effect data and the desktop picture is not needed.

In one possible example, if a full screen shot is taken, the full screen is set as the screenshot area, and the desktop picture displayed in the screenshot window is taken as the screenshot result. At this time, special effect editing can be performed in the desktop picture displayed in the screenshot window. If the screenshot is the area screenshot, only a part of the full screen (the desktop picture displayed in the screenshot window) is selected as the screenshot area.

When a desktop picture is displayed in the screenshot window, the second process responds to screenshot area selection operation to obtain position parameters (such as coordinates of the upper left corner and the lower right corner of the screenshot area/center coordinates and the size of the screenshot area) of the screenshot area, wherein the screenshot area selection operation is used for determining that the screenshot is a full-screen screenshot or a region screenshot according to the physical size of the screenshot area; in the screenshot window, the position of the screenshot area is displayed according to the position parameter of the screenshot area, for example, the position of the screenshot area is displayed in a desktop picture in a dotted frame manner. Then, according to the position parameters of the screenshot area, performing screenshot processing on the desktop picture, namely intercepting the screenshot area from the whole desktop picture; and fusing the picture of the screenshot area obtained after the image matting processing with special effect data generated on the screenshot area according to the special effect editing operation to obtain a screenshot result.

After step 107, the second process sends the screenshot result to the data sharing location of the operating system and notifies the first process that the screenshot is complete, so that the first process ends the second process.

The data sharing location is a location for sharing data in the operating system, such as a clipboard, and the clipboard can store the shared data because the clipboard occupies a certain storage space in the memory.

In a possible example, after the screenshot is completed, the second process may not be ended, that is, the second process may reside in the background, or the first process ends the second process when the idle time of the second process exceeds the idle time threshold, so that when the screenshot operation of the user is received, the second process for creating the screenshot does not need to be created again by the first process, the screenshot-related operation can be directly executed by the second process, the response speed is faster, and the efficiency is higher. And the second process sends a system message to the first process by using the system interface to inform the first process that the screenshot is finished, generates a process ending message after the first process receives the system message, and sends the process ending message to the second process to end the second process. . And then, if the host process needs to use the screenshot result, directly calling the screenshot result in the data sharing position.

In the above steps, the desktop pictures of the main display and the sub display, the pictures of the screenshot area and the merged screenshot result are all stored in the memory, and after the screenshot is finished and the second process is finished, the operating system cleans the desktop pictures and the pictures of the screenshot area stored in the memory.

Therefore, the embodiment of the invention carries out screenshot related processing operation through the second process, and can avoid the influence on the first process when the screenshot is abnormal. And the second process obtains the scanning density of the target display, and further can determine the physical sizes of the screenshot window and the desktop picture in the screenshot window, so that the screenshot window and the desktop picture can be correctly displayed without exceeding the display range of the display and causing a black edge to appear due to undersize. And generating a screenshot result according to the desktop picture in the screenshot window, so that not only can accurate screenshot be realized, but also the screenshot result can be brought with special effect data displayed on the screenshot result.

The screenshot processing method is described below by taking an extended mode as an example, referring to fig. 3B, where fig. 3B is a schematic flowchart of the screenshot processing method provided by the embodiment of the present invention, and the screenshot processing method will be described with reference to the steps shown in fig. 3B.

In step 301, a first process serializes effect data to obtain a byte sequence;

in step 302, the first process creates a second process for screenshot;

in step 303, the first process sends a byte sequence to the second process;

in step 304, the second process deserializes the byte sequence to obtain effect data;

in step 305, the second process obtains a scan density of the main display and the at least one sub-display;

in step 306, the second process obtains desktop pictures of the main display and the at least one sub-display;

in step 307, the second process determines the physical sizes of the desktop pictures of the main display and the at least one sub-display according to the scanning densities of the main display and the at least one sub-display respectively;

in step 308, the second process creates a partial screenshot window in the main display according to the physical size of the desktop picture of the main display;

in step 309, the second process creates a partial screenshot window in the at least one secondary display according to the physical size of the desktop picture of the at least one secondary display;

in step 310, the second process combines partial screenshot windows of the main display and the at least one secondary display into a complete screenshot window;

in step 311, the second process displays desktop pictures of the main display and the at least one sub-display in the complete screenshot window;

in step 312, the second process displays the special effect that can be added in the complete screenshot window according to the effect data;

in step 313, in response to a special effect editing operation on the desktop pictures of the main display and the at least one sub-display based on the special effect, the second process fuses the desktop pictures with special effect data generated according to the special effect editing operation to obtain a screenshot result;

in step 314, the second process sends the screenshot result to a data sharing location of the operating system, and generates a system message;

in step 315, the second process sends a system message to the first process;

in step 316, the first process generates an end process message;

in step 317, the first process sends a finish process message to the second process;

in step 318, the second process ends.

Wherein, in the extended mode, the target display is a main display and at least one sub-display. For the detailed description of the above steps, reference may be made to the above description, which is not repeated herein.

In the following, an exemplary application of the embodiments of the present invention in a practical application will be described. In different stages of the application, the electronic device needs to perform different operations to realize accurate screenshots in the application. The following description will be made of an embodiment of the present invention in terms of two phases, a code development phase of an application and an operation phase of the application.

1. In the code development phase of an application

In the code development stage of the application program, codes related to screenshot in a main project used by a main process of the application program need to be determined, engineering split is carried out, namely the codes related to the screenshot are separated from the main project and are used as screenshot projects used by a subprocess of the screenshot, and the screenshot projects are independent from the main project. At the portal of the screenshot project there is code for creating a screenshot window. After the engineering split is completed, the screenshot engineering statement is the display level perception, and therefore the screenshot aiming at any display can be guaranteed to obtain the scanning density of the corresponding display.

2. In the application program running stage, different screenshot scenes are used for explanation

Scene 1: in the expansion mode, the target display is a main display and at least one auxiliary display, and full screen/area screenshot is carried out.

Referring to fig. 6, fig. 6 is a schematic flowchart of a screenshot provided in an embodiment of the present invention. In the extended mode, the main display and the sub-display are used as a complete (virtual) display, and the full screen shot actually forms a shot that includes both the desktop pictures of the main display and the desktop pictures of the sub-display.

Referring to fig. 7, fig. 7 is a schematic diagram of a screenshot of a session window in an application program according to an embodiment of the present invention. In the process of operating the application program in the auxiliary display desktop, a user triggers screenshot through certain operation, for example, presses a screenshot shortcut key such as "shift + alt + a", or clicks a screenshot button 701 shown in fig. 7. After receiving a trigger screenshot operation of a user, screenshot processing is carried out through the following steps.

Step 1, a main process 601 in fig. 6 acquires effect data (such as characters, mosaics, and invisible watermarks representing user identity information) of a currently logged-in user (such as a local or cloud), converts (serializes) the effect data and merges the effect data into a character string (byte sequence); the main process creates a sub-process for screenshot 602 and passes the serialized string to the sub-process along with other execution parameters of the sub-process (e.g., path parameters, storage location for code pointing to screenshot window); and (4) deserializing the serialized character strings at the entrance of the subprocess to analyze the effect data transmitted by the main process.

The effect data transmitted from the main process to the sub-process may be preset, or may be set only when a screenshot operation is triggered in a window of the main process, including related data such as an invisible watermark (including identity information), text, mosaic, and the like.

If the identity information of the login user needs to be implanted in the effect data, the sub-process cannot acquire the identity information, so that the main process can only transmit the identity information to the sub-process; if the user's identity information is not included in the effects data, the step of "the main process passing the effects data to the sub-process" may be by default. Special effect setting function is provided for users in the screenshot window of the sub-process.

And 2, respectively reading the scanning densities of the main display and the auxiliary display by the subprocess through screenshot engineering, and calculating the physical sizes of the desktop pictures of the main display and the auxiliary display according to the scanning densities of the main display and the auxiliary display.

The electronic equipment reads the scanning density of the main display and the sub display, determines the resolution of the desktop pictures of the main display and the sub display, obtains the physical width of the desktop pictures of the main/sub display according to the ratio of the horizontal resolution of the desktop pictures of the main/sub display to the scanning density of the main/sub display, and obtains the physical height of the desktop pictures of the main/sub display according to the ratio of the vertical resolution of the desktop pictures of the main/sub display to the scanning density of the main/sub display.

And 3, creating a screenshot window by the subprocess according to the physical size obtained in the step 2, acquiring desktop pictures of the main display and the auxiliary display by calling an interface, splicing the desktop pictures of the main display and the auxiliary display into a complete picture according to respective physical sizes, and displaying the complete picture in the screenshot window.

The sub-process creates a screenshot window in a virtual display composed of a main display and a sub-display, the physical size of the screenshot window being equal to the physical size of the outermost rectangle of the desktop pictures of the main display and the sub-display.

The sub-process calls an operating system interface to respectively obtain desktop pictures of the main display and the auxiliary display; the os interface is an interface that the os opens to an application program, such as DX GI (DirectX Graphics in architecture) provided by Windows system, and the interface parameters include screenshot time and display identifier. When the interface is called, the mirror image drive of the operating system reads and outputs the image corresponding to the display identifier and the screenshot time from the display memory. In step 3, the sub-process further supports to further select a screenshot area in the screenshot window to perform area screenshot, and performs a screenshot operation according to the position parameters (such as the coordinates of the upper left corner and the lower right corner/the center coordinates and the pixel width and the pixel height of the area) of the screenshot area, and the obtained picture of the screenshot area is stored in the memory.

Step 4, the subprocess displays special effects which can be added in the screenshot window, such as watermarks, mosaics, characters and the like, in a toolbar of the screenshot window; at this time, the user can call the toolbar to carry out special effect editing on the picture in the screenshot window, and special effect data is stored. As shown in toolbar 702 in fig. 7. Step 4 includes the following two cases.

4.1, the sub-process receives effect data (such as effect data embedded with user identity information) sent by the main process, displays effects which can be added into the screenshot in a toolbar, and supports the setting of the effects (such as the setting of the number, the display position and the effects) of the pictures through the toolbar.

4.2, no matter whether the effect data sent by the main process is received or not, the sub-process can present a special effect toolbar in the screenshot window, and special effect setting of the picture is supported through the toolbar.

And 5, fusing the special effect data added into the screenshot with the picture of the screenshot area in the memory by the subprocess.

The fusion mode is various, and taking the watermark as an example, the explicit watermark can be directly displayed on the screenshot, or the implicit watermark can be written into the picture data but not directly rendered on the picture.

And 6, after data fusion, saving the picture (final screenshot) of the screenshot area fused with the special effect data into a picture file, outputting the picture file to a system clipboard, simultaneously sending a system message WM _ COPYDATA (for data transmission among processes) to the main process by using a system interface function, informing the main process that screenshot is finished, generating a process ending message after the main process receives the system message, and sending the process ending message to the sub-process to end the sub-process. And simultaneously cleaning the picture data in the memory and the picture in the screenshot area.

If the sub-process needs to bring the execution result information which does not include the final screenshot to the main process, the required data can be packaged in the sub-process and sent to the main process through the parameter of the WM _ COPYDATA. In addition, because the system interface function is executed synchronously, the subprocess can destroy the encapsulated data after the main process finishes receiving the data, and the abnormal phenomenon that the memory is released before the data is completely sent can not occur. And if the main process needs to use the final screenshot, directly calling the picture file in the clipboard.

Scene 2: in the copy mode, the target display is a primary/secondary display, and full screen/area screenshot is performed.

In a scene 2, triggering a screenshot in the process that a user operates an application program in a desktop of a main/auxiliary display; the electronic equipment acquires desktop pictures of a main display and a secondary display; and displaying a screenshot window in the desktop of the main/auxiliary display, and displaying desktop pictures of the main/auxiliary display in the screenshot window of the main/auxiliary display.

Scene 3: single screen mode.

In scenario 3, there is only one display, and at this time, the screenshot does not have a problem, and the screenshot process is similar to that in scenario 2.

Continuing with the exemplary structure of the screenshot processing apparatus 255 provided by the embodiment of the present invention implemented as a software module, in some embodiments, as shown in fig. 2, the software module stored in the screenshot processing apparatus 255 of the memory may include: a creation module 2551 for creating a second process for screenshot by the first process of the application; an obtaining module 2552, configured to obtain, by the second process, a scan density of the target display; the target display is a display which needs to be subjected to screenshot; a determining module 2553, configured to obtain a desktop image of the target display in the second process, and determine a physical size of the desktop image according to the scan density of the target display; a display module 2554, configured to create a screenshot window conforming to a physical size in the second process, and display a desktop picture in the screenshot window; and the screenshot generating module 2555 is configured to generate a screenshot result according to the desktop picture in the screenshot window in the second process.

In some embodiments, a creation module to: when a first process of an application program is a main process of the application program and the first process is started, the first process creates a second process, or when the first process receives a screenshot instruction sent by an operating system, the first process creates the second process; the first process sends the path parameters of the codes of the screenshot window to the second process; and the path parameters are used for enabling the second process to read codes of the screenshot window according to the path parameters and create the screenshot window conforming to the physical size when the physical size is obtained.

In some embodiments, the obtaining module is to: the second process declares to the operating system a scan density awareness mode of the second process as display-level awareness to query the operating system for scan density of the target display.

In some embodiments, the determining module is to: calling a screenshot interface of the operating system by the second process to acquire a desktop picture matched with the identifier of the target display and the screenshot time from the screenshot interface; and determining the ratio of the pixel width of the desktop picture to the scanning density of the target display as the physical width of the desktop picture in the target display, and determining the ratio of the pixel height of the desktop picture to the scanning density of the target display as the physical height of the desktop picture in the target display.

In some embodiments, a display module to: and the second process creates a screenshot window conforming to the physical width and the physical height in the target display according to the physical width and the physical height of the desktop picture in the target display.

In some embodiments, the display module is further configured to: when in the extended mode, the target display includes a primary display and a secondary display; and displaying the desktop picture of the main display in the partial screenshot window created by the main display, and displaying the desktop picture of the auxiliary display in the partial screenshot window created by the auxiliary display.

In some embodiments, the screenshot generation module is to: the method comprises the steps that a first process obtains effect data of a screenshot, serializes the effect data into a byte sequence, and sends the byte sequence to a second process; the second process deserializes the byte sequence to obtain effect data; displaying an added special effect in a toolbar of the screenshot window according to the effect data; and responding to the special effect editing operation of the desktop picture based on the special effect, fusing the desktop picture and the special effect data generated according to the special effect editing operation, and obtaining a screenshot result.

In some embodiments, the screenshot generation module is further to: the second process responds to the screenshot area selection operation and obtains the position parameters of the screenshot area; and in the screenshot window, displaying the position of the screenshot area according to the position parameter of the screenshot area.

In some embodiments, the screenshot generation module is further to: performing cutout processing on the desktop picture according to the position parameter of the screenshot area; and fusing the picture of the screenshot area obtained after the matting processing with special effect data generated according to the special effect editing operation.

In some embodiments, the screenshot generation module is further to: and the second process sends the screenshot result to a data sharing position of the operating system and informs the first process of completing screenshot so that the first process ends the second process.

Embodiments of the present invention provide a computer-readable storage medium storing executable instructions, which when executed by a processor, cause the processor to perform a screenshot processing method provided by an embodiment of the present invention, for example, the screenshot processing method shown in fig. 3A.

In some embodiments, the computer-readable storage medium may be memory such as FRAM, ROM, PROM, EP ROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.

In some embodiments, executable instructions may be written in any form of programming language (including compiled or interpreted languages), in the form of programs, software modules, scripts or code, and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.

By way of example, executable instructions may correspond, but do not necessarily have to correspond, to files in a file system, and may be stored in a portion of a file that holds other programs or data, such as in one or more scripts in a hypertext Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub-programs, or portions of code).

By way of example, executable instructions may be deployed to be executed on one computing device or on multiple computing devices at one site or distributed across multiple sites and interconnected by a communication network.

In summary, in the embodiment of the present invention, the first process creates the second process for screenshot processing, and since the screenshot processing is decoupled from the first process, the workload of the first process can be reduced, and the stable operation of the first process is ensured; and in the second process, the screenshot window is created according to the scanning density of the target display, so that the physical size of the screenshot window can be adapted to the target display, and the accuracy of the screenshot result generated based on the screenshot window is further ensured.

The above description is only an example of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, and improvement made within the spirit and scope of the present invention are included in the protection scope of the present invention.

26页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:智能体控制装置、智能体控制方法、以及非临时性的记录介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类