Home > Software engineering >  How to calculate to draw the whole picture of graphics memory space of the size?
How to calculate to draw the whole picture of graphics memory space of the size?

Time:10-25

How the pattern to draw the whole picture of the size of the memory space, and how to allocate memory size in MFC?

CodePudding user response:

Help!!!!!!

CodePudding user response:

In what way? Post your drawing code

CodePudding user response:

refer to the second floor lx624909677 response:
in what way? Post your drawing code
I am the way with double buffer drawing, but this method is draw the figure of too big can't handle, so want to use the way of local re-paint, is to compare the memory and bitmap size, if the bitmap is large, then draw the part of the bitmap, along with the pull of the scroll bar in drawing wasn't part of the display, but how can allocate memory and how to compare the size I will not deal with, please help!!!!!!
 void CDrawView: : ontouch * pDC (CDC) 
{
CDrawDoc * pDoc=GetDocument ();
ASSERT_VALID (pDoc);
//TODO: add the draw code for native data here

CRect client;
PDC - & gt; GetClipBox (the client);
CRect the rect=client;
GetClientRect (the rect);
CMemDC memdc (pDC);

The CBrush brush;
if(! Brush. CreateSolidBrush (RGB (255255255)))
return;
Brush. UnrealizeObject ();
Memdc. FillRect (client, & amp; Brush);

The CBrush brush1;

if(! Brush1. CreateSolidBrush (RGB (255255255)))
return;
CPen pen;
if(! Pen. CreatePen (PS_SOLID, 1, RGB (0, 0)))
return;
The CBrush * pOldBrush;
CPen * pOldPen;
POldPen=memdc. SelectObject (& amp; Pen);
POldBrush=memdc. SelectObject (& amp; Brush1);
Int m_nwidth=memdc. GetDeviceCaps (LOGPIXELSX);///horizontal pixel points per inch
DrawWell (& amp; Memdc);
LoadBmp (& amp; Memdc);
Memdc. SetBkMode (TRANSPARENT);
}

CodePudding user response:

Every time you can it in the map, the map is calculated according to the position of the scroll bar in the area, and then map, only the line, the specific code realization, you can search: picture control supports a scroll bar display images, this kind of solution, such as under this demo can be reference: http://download.csdn.net/detail/u010937817/6025845

CodePudding user response:

CreateFileMapping

CodePudding user response:

reference 4 floor lx624909677 response:
you can, at the time of each map, the map is calculated according to the position of the scroll bar in the area, and then map, only the line, the specific code realization, you can search: picture control supports a scroll bar display images, this kind of solution, such as the demo can refer to: http://download.csdn.net/detail/u010937817/6025845
first calculates the whole images used in the mapped memory size, and then determine whether memory space disposable draw a complete picture of graphics, if can be directly allocated memory to the memory size used to draw the whole picture, otherwise, the plot to a certain proportion can be reduced, and then in judging whether drawing, if can the size of the allocated memory, or repeated until success does set the size of the allocated memory bitmap, make sure the memory, in the window to redraw, also according to the logic of memory bitmap coordinates and the coordinates of the client area to ensure that the client area within the memory bitmap, and then to copy, like this, and I was using a single document: ,

CodePudding user response:

Generally, 24 bitmap length * width * 3 + n adjust bytes (number of bytes in a row must be in multiples of 4)
32-bit figure: length * width * 4

CodePudding user response:

refer to 6th floor edenluck response:
Quote: refer to 4th floor lx624909677 response:

Every time you can it in the map, the map is calculated according to the position of the scroll bar in the area, and then map, only the line, the specific code realization, you can search: picture control supports scrolling display images, this kind of solution, such as the demo can refer to: http://download.csdn.net/detail/u010937817/6025845
first calculates the whole images used in the mapped memory size, and then determine whether memory space disposable draw a complete picture of graphics, if can be directly allocated memory to the memory size used to draw the whole picture, otherwise, the plot to a certain proportion can be reduced, and then determine whether to draw, if can the size of the allocated memory, or repeated until success does set the size of the allocated memory bitmap, make sure the memory, in the window to redraw, also according to the logic of memory bitmap coordinates and the coordinates of the client area to ensure that the client area within the memory bitmap, and then to copy, like this, and I was using a single document: ,

Single document is there something in particular? Way of drawing are the same, the key is to set the map of the area, or you figure how big is the biggest

CodePudding user response:

In fact, this method many, similar to the game scene manager,

First, you should have the concept of the viewport, the whole scene may be much larger than the viewport, such as playing warcraft, LOL, the map is very big, can be rolling on the screen, a viewport is a rectangular area, in fact is used to cut you can see that part of the map of rectangular area ,

Then, you need to understand a truth, any visual image rendering work outside of the mouth is invalid, but not including collision detection, position change, such as physical computing

May contain multiple objects in a scene, multilayer frame, for example, the bottom is map, above is your hero and some monsters, these are to be rendered objects,

Therefore:
1, a good rendering engine, which should be rapid planning some object (objects) should be rendered, which do not need to apply colours to a drawing, the ideal situation is on the back of every object will go out, such as a box, the box itself although within the viewport, but can't see it on the back of it, so the back can be removed, but it requires a lot of calculation, so you select the eliminating algorithm according to the actual situation, and then will need to apply colours to a drawing object into the rendering pipeline,

2, in the presence of you said, seemingly is a 2 d image display, if an image is very big, can use the memory mapping file form that the API (5 floor) stored on the hard disk, the image is divided into different regions (use 4 forks tree), dynamic load current viewport area adjacent to the memory (which can realize seamless rolling), dynamic update image and show only the images within the viewport,

3, if your scenario is not very big, also can create an off-screen buffer directly, now the video card memory is larger, even if enough memory can also be used to serve as a memory, dynamic update off-screen buffer, then every time you just need to bitblt view inside the mouth area,

CodePudding user response:

refer to the eighth floor lx624909677 response:
Quote: refer to the sixth floor edenluck response:

Quote: refer to 4th floor lx624909677 response:

Every time you can it in the map, the map is calculated according to the position of the scroll bar in the area, and then map, only the line, the specific code realization, you can search: picture control supports scrolling display images, this kind of solution, such as the demo can refer to: http://download.csdn.net/detail/u010937817/6025845
first calculates the whole images used in the mapped memory size, and then determine whether memory space disposable draw a complete picture of graphics, if can be directly allocated memory to the memory size used to draw the whole picture, otherwise, the plot to a certain proportion can be reduced, and then determine whether to draw, if can the size of the allocated memory, or repeated until success does set the size of the allocated memory bitmap, make sure the memory, in the window to redraw, also according to the logic of memory bitmap coordinates and the coordinates of the client area to ensure that the client area within the memory bitmap, and then to copy, like this, and I was using a single document: ,

Single document is there something in particular? Way of drawing are the same, the key is to set the map of the area, or how much you figure the largest
sometimes exceed the system memory, is the logging curve is drawn

CodePudding user response:

references 9 f sdhexu response:
actually a lot of this approach, the manager is similar to the game scene,

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related