我在win32視窗中加載一張位圖后如何將它洗掉
uj5u.com熱心網友回復:
洗掉是什么意思?從記憶體中洗掉掉嗎,還是把檔案從磁盤上洗掉掉?你是如何加載的?對應加載都有釋放的函式,如果只用win32 api,那一般就是DeleteObject()
uj5u.com熱心網友回復:
洗掉檔案?還是洗掉句柄?
如果是洗掉檔案,目的是什么?不讓用戶看到檔案?
這種情況你可以把檔案放到資源里面直接加載資源,不會有檔案放到磁盤上的。
句柄的話直接關閉就好了。
uj5u.com熱心網友回復:
Operations on Graphic ObjectsAfter an application creates a display or printer device context, it can begin drawing on the associated device or, in the case of the memory device context, it can begin drawing on the bitmap stored in memory. However, before drawing begins and sometimes while drawing is in progress, it is often necessary to replace the default objects with new objects.
An application can examine a default object's attributes by calling the GetCurrentObject and GetObject functions. The GetCurrentObject function returns a handle identifying the current pen, brush, palette, bitmap, or font, and the GetObject function initializes a structure containing that object's attributes.
Some printers provide resident pens, brushes, and fonts that can be used to improve drawing speed in an application. Two functions can be used to enumerate these objects: EnumObjects and EnumFontFamilies. If the application must enumerate resident pens or brushes, it can call the EnumObjects function to examine the corresponding attributes. If the application must enumerate resident fonts, it can call the EnumFontFamilies function (which can also enumerate GDI fonts).
Once an application determines that a default object needs replacing, it creates a new object by calling one of the following creation functions.
Graphics Object Function
Bitmap CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDiscardableBitmap, CreateDIBitmap
Brush CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush
Color Palette CreatePalette
Font CreateFont, CreateFontIndirect
Pen CreatePen, CreatePenIndirect, ExtCreatePen
Region CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreatePolyPolygonRgn, CreateRectRgn, CreateRectRgnIndirect, CreateRoundRectRgn
Each of these functions returns a handle identifying a new object. After an application retrieves a handle, it must call the SelectObject function to replace the default object. However, the application should save the handle identifying the default object and use this handle to replace the new object when it is no longer needed. When the application finishes drawing with the new object, it must restore the default object by calling the SelectObject function and delete the new object by calling the DeleteObject function. Failing to delete objects causes serious performance problems.
uj5u.com熱心網友回復:
螢屏上,使用背景覆寫位圖所在區域,記憶體,使用DeleteObject洗掉加載的位圖,如果必要使用delete釋放相關記憶體轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/82912.html
標籤:界面
