A kind of WMF fire-fighting graphic processing method and device based on OPENGL
Technical field
The present invention relates to administration of the prevention and control technical fields, and in particular to a kind of WMF fire-fighting graphics process side based on OPENGL
Method and device.
Background technique
Graphic display device of fire control room is a graphics device in fire-fighting linkage control system, it is in fire-fighting
It is the monitoring arrangement that the multidate information of all fire-fighting equipments can be patterned to real-time display and inquiry in control room, master
Wanting function is to receive and show the alarm signal of all kinds of fire-fighting equipments and instantaneous operating conditions and this type of information is transferred to fire-fighting
Wisdom Internet of things system.Graph processing technique is the core function of graphics device, the direct shadow of the superiority and inferiority of graph processing technique
Graphics device is rung to show and the efficiency and performance of query information." GB16806-2006 fire-fighting linkage control system " regulation report
Alert (fire alarm) signal will carry out graphic software platform after issuing in 3s on graphics device, at drawing load time and figure
Reason speed is excessively slow or Caton will have a direct impact on the reception and registration of fire protection warning information and the formulation of fire-fighting and rescue strategy, even meeting when serious
Cause immeasurable loss.
" GA/T 847-2009 graphic display device of fire control room software generic technical requirements " provide fire protection control room figure
The architectural drawing of shape display device software transfer should preferentially use WMF file format.WMF graphical format file has structure to disclose, solve
Analyse easy advantage, further, it is possible to directly export from CAD architectural drawing, software development cost is low, and mainstream disappears currently on the market
Anti- producer is all made of graph processing technique of the technology of parsing WMF file as graphics device software.
But existing WMF graphic file processing technique is directly to carry out figure rendering at the end CPU after parsing WMF file,
It is in high loaded process state due to needing while carrying out work, the CPU such as communication transfer, event parsing and database manipulation,
When load and operation large capacity architectural drawing and large number of equipment pel, graphics process speed is slow, there is apparent Caton phenomenon, and
And performance boost effect is not significant when the high configuration CPU of replacement or exented memory capacity.
Summary of the invention
For overcome the deficiencies in the prior art, it is proposed that a kind of WMF fire-fighting graphic processing method and dress based on OPENGL
It sets, alleviates the processing load of computer CPU, when improving load and operating large capacity architectural drawing and large number of equipment pel
Processing speed.
The invention proposes a kind of WMF fire-fighting graphic processing method based on OPENGL, comprising: parsing WMF fire-fighting figure
Each of file rendering order obtains multiple pel metadata;
The apex coordinate for adjusting each pel metadata makes each apex coordinate surround origin distribution;
World coordinate system is drawn in open GL, and, each pel member is stored in the memory of graphics processor
Data;
Equipment pel data are obtained, the primitive data is stored in the memory of the graphics processor;
According to the identification number of the pel of fire-fighting equipment, the pel member to match is found in the memory of the graphics processor
Data and the primitive data, the pel of fire-fighting equipment is drawn by the graphics processor in the memory.
Further, each of described parsing WMF fire-fighting graphic file rendering order, obtains multiple pel metadata
The step of, comprising:
Parse each of WMF fire-fighting graphic file rendering order, the pel that will need to draw in each rendering order
It is stored according to the primitive types that open GL is supported;
It extracts and records the multiple pel metadata of the pel for needing to draw, wherein the multiple pel metadata includes
The apex coordinate;
Multiple pel metadata are formed into array.
Further, the apex coordinate of each pel metadata of adjustment, encloses each apex coordinate
The step of around origin distribution, comprising:
One by one in the array each pel metadata the distance between apex coordinate and origin;
Select the apex coordinate nearest with initial point distance and the farthest apex coordinate;
Calculate the direction vector at the midpoint between the nearest apex coordinate of distance and the farthest apex coordinate;
Each apex coordinate is translated along the direction vector, each apex coordinate is made to surround origin distribution.
Further, described to draw world coordinate system in open GL, and, it is deposited in the memory of graphics processor
The step of storing up each pel metadata, comprising:
World coordinate system, transformation matrix and tinter are drawn in open GL, wherein the tinter is for rendering
Architectural drawing figure;
Memory is matched for the graphics processor;
Each pel metadata is stored into the memory.
Further, the acquisition equipment pel data, store the pel number in the memory of the graphics processor
According to the step of, comprising:
Equipment pel data are obtained by database or operation of layouting;
Convert the equipment pel data to the type of open GL support;
The primitive data in the memory of the graphics processor after storage conversion.
Further, the identification number of the pel according to fire-fighting equipment, finds in the memory of the graphics processor
The pel metadata to match and the primitive data draw fire-fighting equipment by the graphics processor in the memory
Pel the step of, comprising:
The graphics processor addresses and the identification number phase in the memory according to the identification number of the pel of fire-fighting equipment
The pel metadata matched and the primitive data;
The graphics processor draws fire-fighting equipment according to the pel metadata and the primitive data in the memory
Pel.
Further, the primitive types include point, line segment, broken line, triangle, sector and polygon.
The invention proposes a kind of WMF fire-fighting graphic processing facility based on OPENGL, comprising:
Parsing module obtains multiple pel metadata for parsing each of WMF fire-fighting graphic file rendering order;
Adjust module makes each apex coordinate surround original for adjusting the apex coordinate of each pel metadata
Point distribution;
Coordinate system determining module, for drawing world coordinate system in open GL, and, in the memory of graphics processor
Store each pel metadata;
Memory module stores the primitive data for obtaining equipment pel data in the memory of the graphics processor;
Drafting module finds phase for the identification number of the pel according to fire-fighting equipment in the memory of the graphics processor
The pel metadata matched and the primitive data, the figure of fire-fighting equipment is drawn by the graphics processor in the memory
Member.
The present invention provides a kind of WMF fire-fighting graphic processing method and device based on OPENGL, wherein above-mentioned processing side
Method includes: firstly, each of parsing WMF fire-fighting graphic file rendering order, obtains multiple pel metadata, secondly, adjusting
The apex coordinate of whole each pel metadata makes each apex coordinate surround origin distribution, later, in open GL
World coordinate system is drawn, also, stores each pel metadata in the memory of graphics processor, then, obtains equipment pel
Data store primitive data in the memory of graphics processor, then, according to the identification number of the pel of fire-fighting equipment, in figure
The pel metadata and primitive data to match is found in the memory of processor, is drawn fire-fighting in memory by graphics processor and is set
Standby pel draws WMF fire-fighting figure using open GL in the processing method, and the work that figure renders is transferred to
GPU is handled, to alleviate the workload of CPU, improves load and operation large capacity architectural drawing and large number of equipment figure
Processing speed when first ensure that system smoothness is run, improve the Experience Degree of system performance and user.
To enable the above objects, features and advantages of the present invention to be clearer and more comprehensible, better embodiment is cited below particularly, and match
Appended attached drawing is closed, is described in detail below.
Detailed description of the invention
By referring to the following drawings detailed description of non-limiting embodiments, it can be illustrated more clearly that the present invention
Specific embodiment or technical solution in the prior art, below will be to required in specific embodiment or description of the prior art
The attached drawing used is briefly described, in this way, other features, purposes and advantages of the invention will become more apparent.It is aobvious and easy
Insight, the accompanying drawings in the following description are some embodiments of the present invention, for those of ordinary skill in the art, are not being paid
Out under the premise of creative work, it is also possible to obtain other drawings based on these drawings.
Fig. 1 is a kind of flow chart of the WMF fire-fighting graphic processing method based on OPENGL provided in an embodiment of the present invention;
Fig. 2 is a kind of schematic diagram of the WMF fire-fighting graphic processing facility based on OPENGL provided in an embodiment of the present invention.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right
The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and
It is not used in the restriction present invention.
In view of existing WMF fire-fighting graphic file processing technique be parsing WMF file after directly by the CPU of computer into
The rendering of row figure, the embodiment of the invention provides a kind of WMF fire-fighting graphic processing method and device based on OPENGL;The technology
It can be applied in the places such as fire-fighting graphics process and display, which can be used corresponding software and hardware and realize, right below
The embodiment of the present invention describes in detail.
Embodiment one:
Firstly, referring to Fig.1 come describe the embodiment of the present invention proposition a kind of WMF fire-fighting graphic processing method based on OPENGL,
Specifically includes the following steps:
Step S101: each of parsing WMF fire-fighting graphic file rendering order obtains multiple pel metadata.
Step S102: adjusting the apex coordinate of each pel metadata, and each apex coordinate is made to surround origin distribution.
Step S103: drawing world coordinate system in open GL, and, it is stored in the memory of graphics processor each
A pel metadata.
Step S104: equipment pel data are obtained, store primitive data in the memory of graphics processor.
Step S105: according to the identification number of the pel of fire-fighting equipment, searching matches in the memory of graphics processor
Pel metadata and primitive data are drawn the pel of fire-fighting equipment by graphics processor in memory.
The full name in English Open Graphics of lower open GL (or being called open graphic library) is introduced first
Library, referred to as OpenGL.OpenGL is for rendering compiling across language, cross-platform application program for 2D, 3D vector graphics
Journey interface (API).The efficient realization (graphics accelerator hardware is utilized) of OpenGL is present in Windows, part unix platform and
Mac OS, i.e. OpenGL can be compatible with most of computer.Also, OpenGL specification describes the pumping for drawing 2D and 3D figure
As API, although these API can be by software realization, it is to be designed for most or all using hardware-accelerated.
Secondly introduce full name in English of graphics processor for Graphics Processing Unit, English abbreviation GPU,
GPU is a kind of specially in PC, work station, game machine and some mobile devices (such as tablet computer, smart phone)
Carry out the microprocessor of image operation work.GPU can will show that information carries out conversion driving required for computer system, and
Line scan signals are provided to display, control the correct display of display, are connect display and PC mainboard important
Element.In general, graphics processor is the processor of video card.
Currently, GPU can carry out good interaction with CPU.For example, if CPU thinks one X-Y scheme of picture, it is only necessary to hair
It instructs to GPU, such as " draws the rectangle that a long and width is a × b size at coordinate position (x, y) ", GPU can be counted rapidly
The all pixels of the figure are calculated, and designated position draws corresponding figure over the display, notes that " I draws CPU after painting
It is over ", then waiting for CPU issues next graphics command.As it can be seen that CPU can be from graphics process by the setting of GPU
It is freed in task, goes to execute other more system tasks, and then the overall performance of computer can be greatly improved.
Above-mentioned each step is explained one by one below, it is each in specific above-mentioned parsing WMF fire-fighting graphic file
A rendering order, the step of obtaining multiple pel metadata, comprising:
(1) parse each of WMF fire-fighting graphic file rendering order, by the pel for needing to draw in each rendering order by
The primitive types supported according to open GL are stored.
Since the architectural drawing of regulation graphic display device of fire control room software transfer should be used preferentially in fire protection sector
WMF file format.Therefore, each of WMF fire-fighting graphic file is first parsed in fire-fighting graphic processing method draws life
It enables, to extract the pel for needing to draw in each rendering order.It is stored after getting pel, is specifically deposited
Storage mode is that the primitive types supported according to open GL carry out.What needs to be explained here is that above-mentioned primitive types packet
Include point, line segment, broken line, triangle, sector and polygon.
(2) it extracts and records the multiple pel metadata for needing the pel drawn, wherein multiple pel metadata include top
Point coordinate.
After having stored pel, extracts one by one and record the multiple pel metadata for needing the pel drawn, for example, pel
Type, the vertex quantity of pel, the apex coordinate array of pel, the index of pel, color value of pel etc., in actual implementation mistake
Cheng Zhong, above-mentioned primitive types, the vertex quantity of pel, the apex coordinate array of pel, the index of pel, color value of pel etc.
It can also be collectively referred to as pel metadata.
(3) after getting above-mentioned pel metadata, multiple pel metadata are formed into array.Compared with other forms,
Multiple pel metadata composition array is capable of to the storage form of the more each pel metadata of specification, meanwhile, it is also more convenient
Graphics processor etc. is called by unified label etc..
The apex coordinate of the above-mentioned each pel metadata of adjustment makes each apex coordinate surround the step of origin is distributed,
Include:
(1) during arranging pixel coordinates, to compare the apex coordinate and origin of each pel metadata in array one by one
The distance between, that is, calculate the distance between apex coordinate and origin of each pel metadata.
(2) after the distance between all apex coordinates and origin have been calculated, the length of more each distance is selected and original
Point is apart from nearest apex coordinate and farthest apex coordinate.
(3) it after the apex coordinate nearest and farthest with initial point distance has been determined, calculates apart from nearest apex coordinate
The direction vector at the midpoint between farthest apex coordinate, using the base as the apex coordinate of pel in the above-mentioned array of adjustment
It is quasi-.
(4) when it is implemented, by the apex coordinate of each pel metadata in above-mentioned array along above-mentioned direction vector into
Row translation, so that each apex coordinate be made to surround origin distribution.Step can make the distribution of pixel coordinates more through this process
Add uniformly rationally.
It is above-mentioned to draw world coordinate system in open GL, and, each figure is stored in the memory of graphics processor
The step of meta-meta data, comprising:
(1) it needs first to be configured it before drawing the pel of fire-fighting equipment using open GL, first in open figure
World coordinate system, transformation matrix and tinter are drawn in shape library, wherein tinter is for rendering architectural drawing figure.Pass through
This step realizes the initialization to open GL.
(2) memory is matched for graphics processor after, due to needing to save processing in real time during graphics process
As a result etc., therefore, it is necessary to match memory for graphics processor, to store the apex coordinate and color value of pel.
(3) in addition, storing each pel metadata into memory, for example, above-mentioned primitive types, the number of vertex of pel
Amount, color value of the apex coordinate array of pel, the index of pel, pel etc. are stored into memory, to facilitate graphics process
Device calls.
Above-mentioned acquisition equipment pel data, in the memory of graphics processor the step of storage primitive data, comprising:
(1) equipment pel data are obtained by database or operation of layouting, it in this way being capable of initialization apparatus pel.Above equipment
The selection of the acquisition modes of primitive data according to circumstances can flexibly be chosen.
(2) after getting equipment pel data, equipment pel data are converted to the type of open GL support,
To provide support for subsequent drafting.
(3) also, in the memory of graphics processor the primitive data after conversion is stored, specifically, in above-mentioned memory
Store apex coordinate, texture picture and the texture coordinate of equipment pel, texture, transformation square of the initialization for rendering apparatus pel
Battle array and tinter.
The identification number of the above-mentioned pel according to fire-fighting equipment finds the pel member to match in the memory of graphics processor
Data and primitive data, the step of drawing the pel of fire-fighting equipment in memory by graphics processor, comprising:
(1) graphics processor addresses the pel member to match with identification number according to the identification number of the pel of fire-fighting equipment in memory
Data and primitive data.
It should be noted that above-mentioned identification number is usually the index and type of pel, i.e., when it is implemented, according to above-mentioned rope
Draw and addresses corresponding pel metadata (for example, apex coordinate) and primitive data in memory with type (for example, the face of pel
Color value), it should be added that, the matching relationship of identification number and pel metadata and primitive data is pre-set.
(2) after getting the above-mentioned pel metadata and primitive data to match, graphics processor is according to pel member number
According to the pel for drawing fire-fighting equipment in memory with primitive data.With the mode of the existing pel for drawing fire-fighting equipment by CPU
Difference, the process of above-mentioned drafting is handled by graphics processor (GPU), to alleviate the workload of CPU, improve load and
Operate processing speed when architectural drawing and large number of equipment pel.
A kind of WMF fire-fighting graphic processing method based on OPENGL provided in an embodiment of the present invention includes: firstly, parsing
Each of WMF fire-fighting graphic file rendering order, obtains multiple pel metadata, secondly, adjusting each pel metadata
Apex coordinate, make each apex coordinate surround origin distribution, later, world coordinate system is drawn in open GL,
And each pel metadata is stored in the memory of graphics processor, then, equipment pel data are obtained, in graphics processor
Memory in store primitive data, then, according to the identification number of the pel of fire-fighting equipment, found in the memory of graphics processor
The pel metadata and primitive data to match is drawn the pel of fire-fighting equipment, above-mentioned use by graphics processor in memory
In method of the open GL to draw WMF fire-fighting figure, the work that figure renders is transferred into GPU to handle, is mitigated significantly
The workload of CPU, processing speed when can be improved load in this way and operating large capacity architectural drawing and large number of equipment pel
Degree, further ensures fire protection warning information and quickly and effectively conveys.
Embodiment two:
A kind of WMF fire-fighting graphic processing facility based on OPENGL of proposition of the embodiment of the present invention, the processing are described referring to Fig. 2
Device specifically includes:
Parsing module obtains multiple pel metadata for parsing each of WMF fire-fighting graphic file rendering order;
Module is adjusted, for adjusting the apex coordinate of each pel metadata, each apex coordinate is made to surround origin distribution;
Coordinate system determining module, for drawing world coordinate system in open GL, and, in the memory of graphics processor
Store each pel metadata;
Memory module stores primitive data in the memory of graphics processor for obtaining equipment pel data;
Drafting module, for the identification number of the pel according to fire-fighting equipment, searching matches in the memory of graphics processor
Pel metadata and primitive data are drawn the pel of fire-fighting equipment by graphics processor in memory.
A kind of WMF fire-fighting graphic processing facility based on OPENGL provided in an embodiment of the present invention, mentions with above-described embodiment
A kind of WMF fire-fighting graphic processing method technical characteristic having the same based on OPENGL supplied, so also can solve identical
Technical problem reaches identical technical effect.
The above shows and describes the basic principles and main features of the present invention and the advantages of the present invention, for this field skill
For art personnel, it is clear that invention is not limited to the details of the above exemplary embodiments, and without departing substantially from spirit of the invention or
In the case where essential characteristic, the present invention can be realized in other specific forms.Therefore, in all respects, should all incite somebody to action
Embodiment regards exemplary as, and is non-limiting, the scope of the present invention by appended claims rather than on state
Bright restriction, it is intended that including all changes that fall within the meaning and scope of the equivalent elements of the claims in the present invention
It is interior.Any reference signs in the claims should not be construed as limiting the involved claims.
In addition, it should be understood that although this specification is described in terms of embodiments, but not each embodiment is only wrapped
Containing an independent technical solution, this description of the specification is merely for the sake of clarity, and those skilled in the art should
It considers the specification as a whole, the technical solutions in the various embodiments may also be suitably combined, forms those skilled in the art
The other embodiments being understood that.