Tuesday, October 26, 2010

Initial bitmap


In this lesson we will learn how to use bitmap in the program. More precisely, we have to learn is how the client area of a window to display the bitmap.
Theory
Bitmap is stored in a computer in the picture. A considerable number of bitmap file format (Translation: If. BMP.JPG.GIF.PIC, etc.), but Windows only supports Windows Bitmap Graphics Format, or BMP file. This course is also referred to bitmap BMP files. Use bitmap easiest way is to define it in the resource file (. Rc) in the. There are two methods defined. The first method is to macro it is defined as an integer, as follows:

# Define IDB_MYB99vMAP 100
IDB_MYB99vMAP B99vMAP "c: projectexample.bmp"
The first line we define an integer with a value of 100 macros. The second line we have to point this macro to be defined integer bitmap, so the compiler will know where the path of the bitmap.
Another method is to give it a name, that is, it is defined as a string, as follows:
MyBitMap B99vMAP "c: projectexample.bmp"
Effects of two methods is the same. Choose a method, depending on the program you like to use integer or string to point to Macro bitmap.
Now that we have the bitmap defined in the resource file, the next step is to make it appear in the window client area.
In the process, we use the API function to obtain the bitmap handle LoadBitmap. Here is the complete LoadBitmap function type:
LoadBitmap proto hInstance: HINSTANCE, lpBitmapName: LPSTR

The function returns a bitmap handle. Function has two parameters, which is the process handle hInstance. lpBitmapName is a pointer to a bitmap name (for the second definition of method). If you use the first definition of method, you can fill point or integer values of a bitmap macro (this value corresponds to the example above is 100, an integer macro is IDB_MYB99vMAP). Here is a simple example:


The first method:
.386
. Model flat, stdcall
................
. Const
IDB_MYB99vMAP equ 100
...............
. Data?
hInstance dd?
..............
. Code
.............
invoke GetModuleHandle, NULL
mov hInstance, eax
............
invoke LoadBitmap, hInstance, IDB_MYB99vMAP
...........

The second method:

.386
. Model flat, stdcall
................
. Data
BitmapName db "MyBitMap", 0
...............
. Data?
hInstance dd?
..............
. Code
.............
invoke GetModuleHandle, NULL
mov hInstance, eax
............
invoke LoadBitmap, hInstance, addr BitmapName
...........

Text access to a device (DC) handle. You can respond to WM_PAINT message received through the API function BeginPaint. If the other message, you can use the API function GetDC access.
Create the memory DC image. The aim is to establish a "hidden drawing paper", the bit map "painted" on it, for buffer purposes. After the completion of this work, we adopted a function of "drawing paper" on the bitmap copy of the real DC. This is quickly displayed on the screen image of the double-buffering technique. (Translation: You can reduce image jitter) this "drawing paper," with the API function CreateCompatibleDC established, following the completion of its type:
CreateCompatibleDC proto hdc: HDC

If the function succeeds, will return to DC memory image that is "drawing paper," the handle.

Now we have the "drawing paper," could place a picture on it. SelectObject API function that can be completed, the first parameter is the "drawing paper," the handle, the second parameter is a bitmap handle, here is the function of the complete type:
SelectObject proto hdc: HDC, hGdiObject: DWORD
Now the bitmap has been drawn in the "drawing paper" has gone. Next we want to copy the bitmap in the real DC. There are many API functions can finish the job, such as BitBlt and StretchBlt. Function BitBlt the contents of only one DC to another DC simply copy, while the function is to automatically adjust StretchBlt copy the contents of the size of the source DC has the purpose to adapt the size of DC's output area, so the former than the latter faster. Here, we only use the function BitBlt, following the completion of its type:
BitBlt proto hdcDest: DWORD, nxDest: DWORD, nyDest: DWORD, nWidth: DWORD, nHeight: DWORD, hdcSrc: DWORD, nxSrc: DWORD, nySrc: DWORD, dwROP: DWORD

hdcDest purpose DC handle.
nxDest, nyDest purpose DC output area of the upper-left corner coordinates.
nWidth, nHeight purpose DC output area length and width.
hdcSrc handle of the source DC.
nxSrc, nySrc source DC in the upper left corner coordinates of area to be copied.
dwROP screen surface computing code (ROP). Copy the contents of the parameter used to determine the color and the color of the original output area by which computing approach. Usually, simply copy the contents of the output area with a overwrite.
All completed, the API function with the release of the bitmap DeleteObject object, that is, the bit map "erase."
You're done! Now come back over the procedure: First, you need to define the bitmap in the resource file. Then, you need to load a bitmap in the program resources, and get a bitmap handle. Then, you need to get a bitmap output area of DC, and the creation of the DC's memory image, and to a bitmap image into the memory DC. Finally the bitmap image copied from the memory DC to DC in the real.
Examples:
.386
. Model flat, stdcall
option casemap: none
include masm32includewindows.inc
include masm32includeuser32.inc
include masm32includekernel32.inc
include masm32includegdi32.inc
includelib masm32libuser32.lib
includelib masm32libkernel32.lib
includelib masm32libgdi32.lib
WinMain proto: DWORD,: DWORD,: DWORD,: DWORD
IDB_MAIN equ 1

. Data
ClassName db "SimpleWin32ASMBitmapClass", 0
AppName db "Win32ASM Simple Bitmap Example", 0

. Data?
hInstance HINSTANCE?
CommandLine LPSTR?
hBitmap dd?

. Code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke GetCommandLine
mov CommandLine, eax
invoke WinMain, hInstance, NULL, CommandLine, SW_SHOWDEFAULT
invoke ExitProcess, eax

WinMain proc hInst: HINSTANCE, hPrevInst: HINSTANCE, CmdLine: LPSTR, CmdShow: DWORD
LOCAL wc: WNDCLASSEX
LOCAL msg: MSG
LOCAL hwnd: HWND
mov wc.cbSize, SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
push hInstance
pop wc.hInstance
mov wc.hbrBackground, COLOR_WINDOW +1
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, OFFSET ClassName
invoke LoadIcon, NULL, IDI_APPLICATION
mov wc.hIcon, eax
mov wc.hIconSm, eax
invoke LoadCursor, NULL, IDC_ARROW
mov wc.hCursor, eax
invoke RegisterClassEx, addr wc
INVOKE CreateWindowEx, NULL, ADDR ClassName, ADDR AppName,
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL,
hInst, NULL
mov hwnd, eax
invoke ShowWindow, hwnd, SW_SHOWNORMAL
invoke UpdateWindow, hwnd
. While TRUE
invoke GetMessage, ADDR msg, NULL, 0,0
. Break. If (! Eax)
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
. Endw
mov eax, msg.wParam
ret
WinMain endp

WndProc proc hWnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM
LOCAL ps: PAINTSTRUCT
LOCAL hdc: HDC
LOCAL hMemDC: HDC
LOCAL rect: RECT
. If uMsg == WM_CREATE
invoke LoadBitmap, hInstance, IDB_MAIN
mov hBitmap, eax
. Elseif uMsg == WM_PAINT
invoke BeginPaint, hWnd, addr ps
mov hdc, eax
invoke CreateCompatibleDC, hdc
mov hMemDC, eax
invoke SelectObject, hMemDC, hBitmap
invoke GetClientRect, hWnd, addr rect
invoke BitBlt, hdc, 0,0, rect.right, rect.bottom, hMemDC, 0,0, SRCCOPY
invoke DeleteDC, hMemDC
invoke EndPaint, hWnd, addr ps
. Elseif uMsg == WM_DESTROY
invoke DeleteObject, hBitmap
invoke PostQuitMessage, NULL
. ELSE
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
. ENDIF
xor eax, eax
ret
WndProc endp
end start

;------------------------------------------------- --------------------
; Resource definitions
;------------------------------------------------- --------------------
# Define IDB_MAIN 1
IDB_MAIN B99vMAP "tweety78.bmp"

Analysis:


# Define IDB_MAIN 1
IDB_MAIN B99vMAP "tweety78.bmp"
Define macro IDB_MAIN integer value of 1, then it points to a resource file in the same directory with the file named "tweety.bmp" bitmap.
. If uMsg == WM_CREATE
invoke LoadBitmap, hInstance, IDB_MAIN
mov hBitmap, eax

In dealing with WM_CREATE message, we pass the API function LoadBitmap loading bitmap resources, and through the function return value to obtain the bitmap handle.
Then, we can place the picture in the window client area.

. Elseif uMsg == WM_PAINT
invoke BeginPaint, hWnd, addr ps
mov hdc, eax
invoke CreateCompatibleDC, hdc
mov hMemDC, eax
invoke SelectObject, hMemDC, hBitmap
invoke GetClientRect, hWnd, addr rect
invoke BitBlt, hdc, 0,0, rect.right, rect.bottom, hMemDC, 0,0, SRCCOPY
invoke DeleteDC, hMemDC
invoke EndPaint, hWnd, addr ps

In this example, we choose in response to WM_PAINT message to draw the bitmap. First we get through the API function l BeginPaint DC client area window handle. Then we created through the API function CreateCompatibleDC memory image of the DC, and through API function SelectObject to bitmap image into memory. Next, we get through the API function GetClientRect the size of the window client area. Finally, we function through the API BitBlt the bitmap image copied from the memory DC to the DC area in the real customers. Finished the work, we release the DC through the API function DeleteDC memory image, with the release of the client area of API functions EndPaint DC, drawing the end of the work.

. Elseif uMsg == WM_DESTROY
invoke DeleteObject, hBitmap
invoke PostQuitMessage, NULL
When we no longer need the bitmap, through the API function DeleteObject to release it.






Recommended links:



Simple four-strokes, cool music box my office you scouring millions of songs



Top Personal Finance



Bee Notes Ongoing Expert Special Offers



Seven Strategies media advertising competition



New Computer Education



STORM two Strokes buttoned brightness adjustment



Streaming media based on: What is Streaming Media



Children's Books List: Foreign Books Victory, Was Embarrassing Domestic Children's Books



"Crocodile Group" under the Chip, "national character"



How can we know that you AUTOCAD Screen shown on the graphs of 1:1



ASF Converter



Infomation Animation Tools



Transport Stream Converter



DVR-MS to MPG



Dynamic library is missing is it fixable



Tuesday, October 5, 2010

Ashes of modern CAE



Most of the technology is there to promote improvements in technology. If the old technology can no longer upgrade
We must break the old thinking to the new structure to replace! This thing is taking place in the modern CAE sector!

Classic CAE software in order to maintain compatibility, have long dragged a heavy burden. Although the share of the market, but the response capacity decreased, can not meet the changing needs of users, like the old car, authoritative but not skillfully. Now, whether it is nonlinear, dynamic, fluid, electromagnetic, or optimization, in all areas of new CAE technology continues to challenge the classic. The CAE industry seems to be experiencing a rebirth of a change, so that modern CAE in the world with renewed vitality. If we observe several currently active in the CAE software market will really appreciate this wonderful change.

Calculation of flexible structure

Most say on the ashes of software should be nonlinear and multi-field coupling technique known ANSYS software.

ANSYS is a fact, with a long history of CAE software, produced in 1970 from the now 36-year history. However, this procedure had a strange experience: the end of last century, ANSYS has not released a new version of the past three years, until she almost lost patience with the user. In fact, this three years, ANSYS has experienced a Nirvana: She's founder, Dr. John Swanson led his team to spend three years, using the latest programming technology to re-write the procedural framework for the classic modern IT technology with ANSYS transformed into a vibrant and new software. Workbench introduction to her loyal customers prove they are not white and so on for three years. ANSYS with her series of excellent patient users of new technologies to give a return: CAD model of a two-way interaction parameters, the assembly of Relationship Intelligence to judge, contact element automatically creates unique variational technique, deep non-linear technology, advanced multi-field coupling technology, high-performance computing first breakthrough 100 million degrees of freedom, the rapid integration of M & A process ... ..., too many of the leading ANSYS technology reflects the young and healthy, to re-establish the procedural framework for the ANSYS many opportunities! Finally jumped in the beginning of this century the world's largest provider of CAE software.

Rigid body dynamics calculation

And compared to traditional rigid body dynamics software, RecurDYN LRT fast horses, young and very fighting.

RecurDYN by Korean FunctionBay company launched the first version in 1997, entered China in 2002. Produced relative to the 70's body dynamics software for nearly 20 years later. But the recursive algorithm in the last century 80's achievements in the rapid development of the RecurDYN special. Even the traditional emotional body dynamics software users have to wonder over this new software excels.

......

Hydrodynamics

In Computational Fluid Dynamics (CFD) in the field looking for second-generation leader, the prime of life CFX software into my eyes.

CFX software produced in the late 90s of last century, than the first generation of CFD software, the new 15 years, only 10 years. The last 10 years, is the world's most advanced CFD technology for 10 years. Therefore, using the second generation of CFD technology, CFX an advantage. As a result of the new structure of modern programming techniques, CFX CFD in absorbing the latest technology when there is no obstacle, and the first generation of CFD software at this time becomes a heavy burden. In the calculation of accuracy, convergence speed and stability and, CFX have outstanding performance. A large number of tests show that, CFX convergence rate faster than the first generation of CFD programs one to two orders of magnitude. AIAA conference in 2003, the organizers use multiple CFD software, the DLR-F6 wing-body combination and the DLR-F6 wing-body combination of a series of engine pylons under the angle of attack aerodynamic drag, lift, pitching moment calculated, CFX calculations show better than the time involved in testing the accuracy of any of a CFD software, showing the advantages of the second generation of CFD technology.

Electromagnetic simulation

In the electromagnetic simulation (CEM) in the field, there is also an exciting scene.

FEKO software industry as a dark horse CEM, interpretation of the new architecture of the old structure of the breakthrough. Finite element method in 70 to the rapid development of the early 80s to early electromagnetic simulation software into the glass roof. Moment method and the high-frequency approximation method in the rapid development of the late 80s, the successful achievement of the FEKO software.

EMSS FEKO from South Africa in 1995, the company launched the first version, entered China in 2001. Later than the same software for almost 20 years, but now has become the CEM software, one of the most unique in the world.

......

Design Optimization

Variational technique based on the design optimization DesignXplorer VT had a fire lit, and the more intense burning.

DesignXplorer VT was introduced in 2001 ANSYS multi-objective optimization software is ANSYS 2000 acquisition of Parametric Technology Corporation CADOE France, will integrate its technology following the launch of the new module Workbench.

Optimization algorithm has become a vast and complex field, now people are still enthusiastic about her. But no matter how good the new algorithm, can not escape his point: the need for a large number of iterative calculations. The more design variables, the more iterations required. Rocket ship for the aircraft or aircraft engine car such a complex product design variables very much, because a large number of iterations required to optimize in fact meaningless. Lushan in the optimization algorithm into the so-called superior algorithm, only quantitative, not qualitative change. But DesignXplorer out of Lushan, creating a surprising way: variational technology (VT: Variational Technology), this technique only one calculation, you can go to the optimization results.

......

Conclusion
There was a saying, "澶ч奔鍚冨皬楸?, warned that if they can not themselves become larger, can be annexed. But the rules of the game in today's world has changed, become "fast fish eat slow fish." Do not you see the big recent acquisition of CAE industry, are a typical "slow fast food" rather than "eat little." If you can not be like the old program ANSYS as Nirvana, you may be new or alternative technology mergers and acquisitions, from the historical stage. No matter how a software will not Nirvana, does not affect the CAE industry, ashes, we are fortunate in growing up in a new era of phoenix wings Jifei!







相关链接:



IMPLEMENT a network bridge firewall



MP4 to 3GP



3GPP converter



MP4 To Flash