// osbview.cpp : implementation of the COSBView class
//
#include "stdafx.h"
#include "math.h"
#include <conio.h>
#include "sdata.h"
#include "mmsystem.h"
#include "dib.h"
#include "dibpal.h"
#include "spriteno.h"
#include "splstno.h"
#include "spritlst.h"
#include "sprite.h"
#include "phsprite.h"
#include "osbview.h"
#define PAI 3.1415926
#define HHH 1024
#define VVV 768
#define TILESIZES 30 /* size of display tiles */
#define SHORTWAIT 1
#define WaitForTick(twait) {\
while((t=timeGetTime()) >= l && t < (l+(long)twait));\
}
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
*/
#define PALETTE_MASK 0x3c6
#define PALETTE_REGISTER_RD 0x3c7
#define PALETTE_REGISTER_WR 0x3c8
#define PALETTE_DATA 0x3c9
/////////////////////////////////////////////////////////////////////////////
// COSBView
//IMPLEMENT_DYNCREATE(COSBView, CScrollView)
/*
BEGIN_MESSAGE_MAP(COSBView, CScrollView)
//{{AFX_MSG_MAP(COSBView)
ON_WM_PALETTECHANGED()
ON_WM_QUERYNEWPALETTE()
ON_WM_SIZE()
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
*/
/////////////////////////////////////////////////////////////////////////////
// COSBView construction/destruction
COSBView::COSBView()
{
m_pThisWnd = NULL;
hInstDll=0;
hLangDll=0;
sFileName.Empty( );
m_pDIB = NULL;
m_pPal = NULL;
m_pOneToOneClrTab = NULL;
m_bUseCreateDIBSection = FALSE;
m_hbmSection = NULL;
m_dx=m_dy=0;
m_DrawRect=CRect(0,0,HHH-1,VVV-1);
// See if we are on Win32s which exports CreateDIBSection but
// does not support it
DWORD dwVer = GetVersion();
if ((dwVer & 0x800000FF) != 0x080000003) {
// Not on Win32s so try to get the CreateDIBSection procedure address.
HANDLE hMod = ::GetModuleHandle("gdi32");
if (hMod) {
m_pCDSProc = (CDSPROC*) GetProcAddress((HMODULE) hMod, "CreateDIBSection");
if (m_pCDSProc) {
m_bUseCreateDIBSection = TRUE;
}
}
}
////////////
m_pBkgndDIB=NULL;
}
COSBView::~COSBView()
{
EmptyCOSBView();
}
void COSBView::EmptyCOSBView()
{
if (m_pDIB) delete m_pDIB;
if (m_pPal) delete m_pPal;
if (m_pOneToOneClrTab) free(m_pOneToOneClrTab);
if (m_hbmSection) ::DeleteObject(m_hbmSection);
EmptyDirtyList();
///////
m_SpriteList.RemoveAll();
m_ButtonList.RemoveAll();
if(m_pBkgndDIB)delete m_pBkgndDIB;
}
// Create a new buffer, tables and palette to match a supplied DIB.
BOOL COSBView::Create(CDIB *pDIB)
{
// Create the 1-to-1 palette index table.
if(pDIB->GetBitCount()==8){
if (m_pOneToOneClrTab) free(m_pOneToOneClrTab);
m_pOneToOneClrTab =
(LPBITMAPINFO) malloc(sizeof(BITMAPINFOHEADER)
+ 256 * sizeof(WORD));
if (!m_pOneToOneClrTab) {
TRACE("Failed to create color table");
return FALSE;
}
// Set up the table header to match the DIB
// by copying the header and then constructing the 1-to-1
// index translation table.
memcpy(m_pOneToOneClrTab,
pDIB->GetBitmapInfoAddress(),
sizeof(BITMAPINFOHEADER));
// make sure the length of the table is set to 256 not to
// the number of colors in the DIB which is irrelevant
m_pOneToOneClrTab->bmiHeader.biClrUsed = 0; // default (256)
WORD* pIndex;
pIndex = (LPWORD)((LPBYTE)m_pOneToOneClrTab + sizeof(BITMAPINFOHEADER));
for (int i = 0; i < 256; i++) {
*pIndex++ = (WORD) i;
}
// Create a palette from the DIB so that we can use it to do
// screen drawing.
if (m_pPal) delete m_pPal;
m_pPal = new CDIBPal;
ASSERT(m_pPal);
if (!m_pPal->Create(pDIB)) {
TRACE("Failed to create palette");
delete m_pPal;
m_pPal = NULL;
return FALSE;
} else {
// Map the colors so that we get an identity palette.
// HDC dc =::GetDC(m_hWnd);
/// int jj= GetDeviceCaps(hdcScreen, NUMCOLORS);
// int jj=::GetDeviceCaps(dc,BITSPIXEL);
// if(jj==8)
// m_pPal->SetSysPalColors();
// ::ReleaseDC(m_hWnd,dc);
}
} // Delete any existing DIB and create a new one.
if (m_pDIB) delete m_pDIB;
m_pDIB = new CDIB;
BOOL bResult = FALSE;
if(pDIB->GetBitCount()==8){
if (m_bUseCreateDIBSection) {
if (m_hbmSection) ::DeleteObject(m_hbmSection);
ASSERT(m_pCDSProc);
CDC* pDC = GetDC();
CPalette* pPalOld = pDC->SelectPalette(m_pPal, FALSE);
pDC->RealizePalette();
BYTE* pBits = NULL;
m_hbmSection = (*m_pCDSProc)(pDC->GetSafeHdc(),
m_pOneToOneClrTab,
DIB_PAL_COLORS,
(VOID **) &pBits,
NULL,
0);
pDC->SelectPalette(pPalOld, FALSE);
ASSERT(m_hbmSection);
ASSERT(pBits);
ReleaseDC(pDC);
bResult = m_pDIB->Create(pDIB->GetBitmapInfoAddress(), pBits);
} else {
bResult = m_pDIB->Create(pDIB->GetWidth(), pDIB->GetHeight());
}
}
else
bResult = m_pDIB->Create(pDIB->GetWidth(), pDIB->GetHeight(),24);
if (!bResult) {
TRACE("Failed to create off-screen DIB");
delete m_pDIB;
m_pDIB = NULL;
return FALSE;
}
CSize sizeTotal;
sizeTotal.cx = m_pDIB->GetWidth();
sizeTotal.cy = m_pDIB->GetHeight();
SetScrollSizes(MM_TEXT, sizeTotal);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// COSBView drawing
void COSBView::OnInitialUpdate()
{
CSize sizeTotal;
if (m_pDIB) {
sizeTotal.cx = m_pDIB->GetWidth();
sizeTotal.cy = m_pDIB->GetHeight();
} else {
sizeTotal.cx = HHH;
sizeTotal.cy = VVV;
}
SetScrollSizes(MM_TEXT, sizeTotal);
}
void COSBView::OnDraw(CDC* pDC)
{
Draw(pDC);
}
/////////////////////////////////////////////////////////////////////////////
// COSBView diagnostics
/*
#ifdef _DEBUG
void COSBView::AssertValid() const
{
CScrollView::AssertValid();
}
void COSBView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CDocument* COSBView::GetDocument() // Non-debug version is inline
{
return m_pDocument;
}
#endif //_DEBUG
*/
/////////////////////////////////////////////////////////////////////////////
// COSBView message handlers
// Draw a section of the off-screen image buffer to the screen.
void COSBView::Draw(CDC* pDC, LPRECT pRect)
{
CDC* pdc;
CRect rcDraw;
// Make sure we have what we need to do a paint.
if (!m_pDIB ) {
TRACE("No DIB or color table to paint from");
return;
}
// See if a DC was supplied, and get one if not.
if (pDC) {
pdc = pDC;
} else {
pdc = GetDC();
}
// See if a clip rect was supplied, and use the client area if not.
if (pRect) {
rcDraw = *pRect;
} else {
GetClientRect(rcDraw);
}
// Get the clip box.
CRect rcClip;
pdc->GetClipBox(rcClip);
// Create a rect for the DIB.
CRect rcDIB;
rcDIB.left = rcDIB.top = 0;
/*
rcDIB.right = m_pDIB->GetWidth() - 1;
rcDIB.bottom = m_pDIB->GetHeight() - 1;
*/
////change by xmy begin2006.11.27
rcDIB.right = m_pDIB->GetWidth() ;
rcDIB.bottom = m_pDIB->GetHeight() ;
////change by xmy end
// Find a rectangle that describes the intersection of the draw
// rect, clip rect, and DIB rect.
CRect rcBlt;
rcBlt.IntersectRect(&rcDraw, &rcClip);
rcBlt.IntersectRe
没有合适的资源?快使用搜索试试~ 我知道了~
libs.rar_c++ 图片类
共205个文件
svn-base:97个
h:60个
cpp:23个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 25 浏览量
2022-09-23
08:34:40
上传
评论
收藏 8.75MB RAR 举报
温馨提示
非常强大的界面设计类,图片的加载与图片换图片,,功能非常的完美了。
资源详情
资源评论
资源推荐
收起资源包目录
libs.rar_c++ 图片类 (205个子文件)
all-wcprops 5KB
all-wcprops 4KB
all-wcprops 780B
all-wcprops 519B
all-wcprops 92B
all-wcprops 92B
GDICPP.CHI 97KB
GDICPP.CHM 3.19MB
Osbview.cpp 187KB
Dib.cpp 56KB
Dib.cpp 54KB
Txt.cpp 37KB
ascavi.cpp 18KB
ascavi.cpp 17KB
Phsprite.cpp 14KB
BSOUND.CPP 12KB
Dibpal.cpp 11KB
WAVE.CPP 10KB
Mysprits.cpp 9KB
Sprite.cpp 7KB
Waveodev.cpp 6KB
MCIOBJ.CPP 5KB
PlayAvi.cpp 4KB
sndmid.cpp 4KB
Spritlst.cpp 4KB
SPLSTNO.CPP 2KB
SOUND.CPP 1KB
Animpath.cpp 982B
Path.cpp 494B
Point.cpp 215B
sdata.cpp 128B
gdiplus.dll 1.63MB
ImageLoad.dll 179KB
entries 6KB
entries 5KB
entries 1KB
entries 784B
entries 215B
entries 215B
format 2B
format 2B
format 2B
format 2B
format 2B
format 2B
GdiPlusGraphics.h 86KB
GdiPlusFlat.h 83KB
GdiPlusEnums.h 47KB
GdiPlusPath.h 46KB
GdiPlusBrush.h 27KB
GdiPlusImaging.h 23KB
GdiPlusBitmap.h 20KB
GdiPlusHeaders.h 19KB
GdiPlusTypes.h 16KB
GdiPlusRegion.h 15KB
GdiPlusPen.h 13KB
GdiPlusimageAttributes.h 13KB
GdiPlusMetaFile.h 12KB
Osbview.h 11KB
GdiPlusColor.h 10KB
GdiPlusMatrix.h 9KB
GdiPlusStringFormat.h 8KB
GdiPlusMetaHeader.h 8KB
GdiPlusLineCaps.h 7KB
Txt.h 6KB
GdiPlusFont.h 6KB
Dib.h 5KB
Dib.h 4KB
GdiPlusFontFamily.h 4KB
imageload.h 4KB
GdiPlusPixelFormats.h 4KB
GdiPlusInit.h 3KB
GdiPlusFontCollection.h 3KB
GdiPlusGpStubs.h 3KB
Phsprite.h 2KB
ascavi.h 2KB
ascavi.h 2KB
GdiPlus.h 2KB
BSOUND.H 2KB
Sprite.h 2KB
GdiPlusColorMatrix.h 2KB
WAVE.H 2KB
GdiPlusImageCodec.h 1KB
GdiPlusCachedBitmap.h 1KB
WAVEODEV.H 1KB
MYSPRITS.H 1022B
Spritlst.h 948B
Animpath.h 909B
SPRITENO.H 882B
SPLSTNO.H 835B
GdiPlusBase.h 833B
GdiPlusMem.h 788B
Dibpal.h 721B
PATH.H 715B
MCIOBJ.H 693B
PlayAvi.h 641B
stdafx.h 583B
Mulsprite.h 565B
sndmid.h 529B
MEM.H 511B
共 205 条
- 1
- 2
- 3
周楷雯
- 粉丝: 80
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0