//////////////////////////////////////////////////
// 1. 软件说明
// 七彩泡泡屏保 Vertion 1.0 Bate
// 2. 作成者
// 2010.04.08 臧義昌 QQ:545380311
//////////////////////////////////////////////////
#include <windows.h>
#include <math.h>
#include <time.h>
#include <scrnsave.h>
#include "resource.h"
#ifndef ULONG_PTR
#define ULONG_PTR unsigned long*
#endif
#include ".\\gdiplus\\Include\\gdiplus.h"
#pragma comment(lib, ".\\gdiplus\\lib\\gdiplus.lib")
#define BALL_MAX (12)
#define MIN_DISTN (6)
#define BALL_DIMTR (220)
#define NEXT_DISTN (100)
typedef struct
{
int posx, posy;
int verx, very;
int clrIndex;
}BALL;
using namespace Gdiplus;
static BOOL ImageFromIDResource(UINT nID,LPCTSTR sTR,Image * &pImg);
static HBITMAP CopyScreenToBitmap(LPRECT lpRect);
static void UpdateScreen(HWND hWnd, int Transparent=255);
static void BallActPro();
////////////////////////////////////////////
char szIniFileName[]="control.ini";
char szSection[32];
char szEntry[]="Slide Text:";
char SlideText[256];
////////////////////////////////////////////
HDC m_hdc;
HDC m_hdcMemory;
HDC m_hdcScrBmp;
RECT m_ScreenRect;
RECT m_BallPosRect;
int m_ImageWidth, m_ImageHeight;
int m_limt_max, m_limt_min;
ColorMatrix m_colorMatrix =
{
1.0f, 0.0f, 0.0f, 0.15f, 0.0f,
0.0f, 1.0f, 0.0f, 0.15f, 0.0f,
0.0f, 0.0f, 1.0f, 0.15f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 1.0f
};
float m_clrTable[BALL_MAX][3] =
{
0.5f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f,
0.0f, 0.0f, 0.5f,
0.5f, 0.5f, 0.0f,
0.5f, 0.0f, 0.5f,
0.0f, 0.5f, 0.5f,
0.5f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f,
0.0f, 0.0f, 0.5f,
0.5f, 0.5f, 0.0f,
0.5f, 0.0f, 0.5f,
0.0f, 0.5f, 0.5f,
};
BALL m_balls[BALL_MAX];
Image *m_pImageball[BALL_MAX];
int m_ball_cnt = 0;
LRESULT WINAPI ScreenSaverProc(HWND hWnd,UINT message, WPARAM wParam,LPARAM lParam)
{
static UINT timerID;
static ULONG_PTR gdiplusToken;
static HBITMAP hScreenBmp;
static HBITMAP hBitMap;
int i;
Color blank(0, 0, 0, 0);
Image *pImageBallBk = NULL;
Image *pImageBallFt = NULL;
Image *pImageLogo = NULL;
Image *pImageBlank = NULL;
Graphics *graph = NULL;
GdiplusStartupInput gdiplusStartupInput;
switch (message)
{
case WM_CREATE:
memset(m_balls, 0x00, sizeof(m_balls));
memset(m_pImageball, 0x00, sizeof(m_pImageball));
m_hdc = GetDC(hWnd);
m_hdcMemory = CreateCompatibleDC(m_hdc);
m_hdcScrBmp = CreateCompatibleDC(NULL);
//初始化gdiplus的环境
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
ImageFromIDResource(IDR_BALL_BK,"PNG",pImageBallBk);
ImageFromIDResource(IDR_BALL_FT,"PNG",pImageBallFt);
ImageFromIDResource(IDR_LOGO,"PNG",pImageLogo);
m_ImageWidth = pImageBallBk->GetWidth();
m_ImageHeight = pImageBallBk->GetHeight();
ImageFromIDResource(IDR_BALL_BK,"PNG",pImageBlank);
graph = Graphics::FromImage(pImageBlank);
graph->Clear(blank);
delete graph;
graph = NULL;
SetRect(&m_ScreenRect,
0, 0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN));
SetRect(&m_BallPosRect,
m_ScreenRect.left + BALL_DIMTR / 2,
m_ScreenRect.top + BALL_DIMTR / 2,
m_ScreenRect.right - BALL_DIMTR / 2,
m_ScreenRect.bottom - BALL_DIMTR / 2);
m_limt_max = (BALL_DIMTR + MIN_DISTN / 3) * (BALL_DIMTR + MIN_DISTN / 3);
m_limt_min = (BALL_DIMTR - 2 * MIN_DISTN / 3) * (BALL_DIMTR - 2 * MIN_DISTN / 3);
hScreenBmp = CopyScreenToBitmap(&m_ScreenRect);
SelectObject(m_hdcScrBmp,hScreenBmp);
graph = Graphics::FromHDC(m_hdcScrBmp);
graph->DrawImage(
pImageLogo,
Rect(m_ScreenRect.right - pImageLogo->GetWidth() -100,
m_ScreenRect.bottom - pImageLogo->GetHeight() - 80,
pImageLogo->GetWidth(), pImageLogo->GetHeight()));
delete graph;
graph = NULL;
hBitMap = CreateCompatibleBitmap(
m_hdc,
m_ScreenRect.right -m_ScreenRect.left,
m_ScreenRect.bottom -m_ScreenRect.top);
SelectObject(m_hdcMemory, hBitMap);
srand(time(NULL));
for(i = 0; i < BALL_MAX; i++)
{
ImageAttributes imageAttributes;
m_balls[i].posx = m_ScreenRect.left - m_ImageWidth / 2;
m_balls[i].posy = m_ScreenRect.bottom + m_ImageHeight / 2;
m_balls[i].verx = rand()%3 + 1;
m_balls[i].very = -(rand()%3 + 1);
m_balls[i].clrIndex = i;
m_pImageball[i] = pImageBlank->Clone();
graph = Graphics::FromImage(m_pImageball[i]);
m_colorMatrix.m[4][0] = m_clrTable[m_balls[i].clrIndex][0];
m_colorMatrix.m[4][1] = m_clrTable[m_balls[i].clrIndex][1];
m_colorMatrix.m[4][2] = m_clrTable[m_balls[i].clrIndex][2];
imageAttributes.SetColorMatrix(
&m_colorMatrix,
ColorMatrixFlagsDefault,
ColorAdjustTypeBitmap);
graph->DrawImage(
pImageBallBk,
Rect(0, 0, m_ImageWidth, m_ImageHeight), // destination rectangle
0, 0, // upper-left corner of source rectangle
m_ImageWidth, // width of source rectangle
m_ImageHeight, // height of source rectangle
UnitPixel,
&imageAttributes);
graph->DrawImage(
pImageBallFt,
Rect(0, 0, m_ImageWidth, m_ImageHeight), // destination rectangle
0, 0, // upper-left corner of source rectangle
m_ImageWidth, // width of source rectangle
m_ImageHeight, // height of source rectangle
UnitPixel,
&imageAttributes);
delete graph;
graph = NULL;
}
delete pImageBlank;
pImageBlank = NULL;
delete pImageBallBk;
pImageBallBk = NULL;
delete pImageBallFt;
pImageBallFt = NULL;
timerID=SetTimer(hWnd, 1, 20, NULL);
break;
case WM_ERASEBKGND:
OutputDebugString("/////////////////////////////////////////\n");
OutputDebugString("WM_ERASEBKGND\n");
OutputDebugString("/////////////////////////////////////////\n");
UpdateScreen(hWnd);
return 1;
case WM_TIMER:
UpdateScreen(hWnd);
break;
case WM_DESTROY:
KillTimer(hWnd,timerID);
for(i = 0; i < BALL_MAX; i++)
{
delete m_pImageball[i];
m_pImageball[i] = NULL;
}
GdiplusShutdown(gdiplusToken);
DeleteObject(hScreenBmp);
DeleteObject(hBitMap);
::ReleaseDC(hWnd,m_hdc);
m_hdc=NULL;
DeleteDC(m_hdcMemory);
m_hdcMemory=NULL;
DeleteDC(m_hdcScrBmp);
m_hdcScrBmp=NULL;
PostQuitMessage (0);
return 0;
}
return DefScreenSaverProc(hWnd,message,wParam,lParam);
}
BOOL WINAPI ScreenSaverConfigureDialog(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
return FALSE;
}
BOOL WINAPI RegisterDialogClasses(HANDLE hInstance)
{
return TRUE;
}
static void UpdateScreen(HWND hWnd, int Transparent)
{
static int count = 0;
if(m_ball_cnt < BALL_MAX)
{
if(count % NEXT_DISTN == 0)
m_ball_cnt++;
count++;
}
BallActPro();
BitBlt(
m_hdcMemory,
0, 0,
m_ScreenRect.right -m_ScreenRect.left,
m_ScreenRect.bottom -m_ScreenRect.top,
m_hdcScrBmp,
0,0,
SRCCOPY);
Graphics graph(m_hdcMemory);
for(int i = 0; i < m_ball_cnt && i < BALL_MAX; i++){
graph.DrawImage(
m_pImageball[i],
Rect((int)(m_balls[i].posx - m_ImageWidth / 2),
(int)(m_balls[i].posy - m_ImageHeight / 2),
m_ImageWidth, m_ImageHeight));
}
BitBlt(m_hdc,
0,0,
m_ScreenRect.right -m_ScreenRect.left,
m_ScreenRect.bottom -m_ScreenRect.top,
m_hdcMemory,
0,0,
SRCCOPY);
return;
}
static BOOL ImageFromIDResource(UINT nID, LPCTSTR sTR,Image * &pImg)
{
HRSRC hRsrc = ::FindResource (hMainInstance,MAKEINTRESOURCE(nID),sTR); // type
if (!hRsrc)
return FALSE;
// load resource into memory
DWORD len = SizeofResource(hMainInstance, hRsrc);
BYTE* lpRsrc = (BYTE*)LoadResource(hMainInstance, hRsrc);
if (!lpRsrc)
return FALSE;
// Allocate global memory on which to create stream
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
MultClrBubbleScreenSaver_V1.0.rar (46个子文件)
MultClrBubbleScreenSaver
gdiplus
Include
GdiPlusPath.h 49KB
GdiPlusFontFamily.h 6KB
GdiPlusTypes.h 18KB
GdiPlusFontCollection.h 3KB
GdiPlusFont.h 6KB
GdiPlusBase.h 931B
GdiPlusEnums.h 55KB
GdiPlusMetaFile.h 12KB
GdiPlusGraphics.h 92KB
GdiPlusImageCodec.h 2KB
GdiPlusFlat.h 85KB
GdiPlusInit.h 3KB
GdiPlusHeaders.h 22KB
GdiPlusColor.h 4KB
GdiPlusPen.h 13KB
GdiPlusimageAttributes.h 13KB
GdiPlusBitmap.h 22KB
GdiPlus.h 3KB
GdiPlusPixelFormats.h 7KB
GdiPlusMetaHeader.h 8KB
GdiPlusRegion.h 13KB
GdiPlusBrush.h 30KB
GdiPlusGpStubs.h 3KB
GdiPlusImaging.h 24KB
GdiPlusMem.h 1KB
GdiPlusStringFormat.h 9KB
GdiPlusColorMatrix.h 2KB
GdiPlusMatrix.h 8KB
GdiPlusCachedBitmap.h 2KB
GdiPlusLineCaps.h 6KB
lib
GdiPlus.lib 196KB
MultClrBubbleScreenSaver.opt 54KB
resource.h 922B
MAINICON.ico 7KB
MultClrBubbleScreenSaver.cpp.bak 11KB
MultClrBubbleScreenSaver.dsp 5KB
MultClrBubbleScreenSaver.plg 2KB
MultClrBubbleScreenSaver.rc 3KB
BALL_FT.png 19KB
MultClrBubbleScreenSaver.ncb 65KB
MultClrBubbleScreenSaver.cpp 11KB
Release
MultClrBubbleScreenSaver.scr 96KB
MultClrBubbleScreenSaver.aps 83KB
BALL_BK.png 17KB
MultClrBubbleScreenSaver.dsw 577B
LOGO.png 7KB
共 46 条
- 1
zangchang
- 粉丝: 4
- 资源: 23
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页