rect

C#调用Win32_的API函数--User32.dll

雨燕双飞 提交于 2019-12-29 08:12:40
来自森大科技官方博客 http://www.cnsendblog.com/index.php/?p=230 GPS平台、网站建设、软件开发、系统运维,找森大网络科技! http://cnsendnet.taobao.com C#调用Win32 的API函数--User32.dll Win32的API函数是微软自己的东西,可以直接在C#中直接调用,在做WinForm时还是很有帮助的。有时候我们之直接调用Win32 的API,可以很高效的实现想要的效果。 代码 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace WindowsAPI { class CSharp_Win32Api { #region User32.dll 函数 /// <summary> /// 该函数检索一指定窗口的客户区域或整个屏幕的显示设备上下文环境的句柄,以后可以在GDI函数中使用该句柄来在设备上下文环境中绘图。hWnd:设备上 下文环境被检索的窗口的句柄 /// </summary> [DllImport("user32.dll", CharSet = CharSet.Auto)] public

VC俄罗斯方块

只愿长相守 提交于 2019-12-29 05:25:00
  用VC撸了一个俄罗斯方块, 实在是内流满面啊, 我屮艸芔茻, 纠结代码: // Blocks.cpp : 定义应用程序的入口点。 #include "stdafx.h" #include "Blocks.h" #include "stdio.h" #include "time.h" #include<stdlib.h> #define MAX_LOADSTRING 100 #define BOUND_SIZE 10 #define TETRIS_SIZE 30 #define GAME_X 10 #define GAME_Y 20 //游戏中方块的类型 int Tetris[][4][4] = { { { 0,0,0,0 }, { 1,1,1,1 }, { 0,0,0,0 }, { 0,0,0,0 } }, { { 1,1,0,0 }, { 1,1,0,0 }, { 0,0,0,0 }, { 0,0,0,0 } }, { { 1,1,0,0 }, { 0,1,1,0 }, { 0,0,0,0 }, { 0,0,0,0 } }, { { 0,1,1,0 }, { 1,1,0,0 }, { 0,0,0,0 }, { 0,0,0,0 } }, { { 1,0,0,0 }, { 1,1,1,0 }, { 0,0,0,0 }, { 0,0,0,0 } } }; //方块的个数 int

Android canvas.drawBitmap讲解

浪子不回头ぞ 提交于 2019-12-28 09:08:19
1,基本的绘制图片方法 drawBitmap(Bitmap bitmap, float left, float top, Paint paint) 参数://Bitmap:图片对象, left:偏移左边的位置,top: 偏移顶部的位置 2, drawBitmap( Bitmap bitmap, Rect src, Rect dst, Paint paint); 这里由2个Rect, 第一个Rect --src 代表要裁剪的bitmap的区域,如传null,表示需要绘制整个图片, 第二个Rect ---det表示需要将bitmap,绘制在屏幕上的位置,不可为空,并且大于src则把src的裁截区放大,小于src则把src的裁截区缩小。 Bitmap bitmap = BitmapFactory.decodeResource(getContext().getResources(),R.drawable.ic_logo); //绘制方法1:---原图,制作偏移 canvas.drawBitmap(bitmap,100,100,mPaint);//将图片从(0,0)位置向左偏移100,向右偏移100 Rect srcRect = new Rect(0,0,bitmap.getWidth()/2,bitmap.getHeight()/2);//截取图片左上1/4的区域 Rect dstRect

C++ Primer Plus (第6版) 中文版 第十一章 使用类 编程练习答案

这一生的挚爱 提交于 2019-12-28 02:47:28
第十一章 编程练习 1 .修改程序清单11.15, 使之将一系列连续的随机漫步者位置写入文件中。对于每个位置,用步号进行标示。另外,让该程序将初始条件(目标距离和步长)以结果小结写入到该文件中。 头文件: // vect.h -- Vector class with <<, mode state # ifndef VECTOR_H_ # define VECTOR_H_ # include <iostream> namespace VECTOR { class Vector { public : enum Mode { RECT , POL } ; // RECT for rectangular, POL for Polar modes private : double x ; // horizontal value double y ; // vertical value double mag ; // length of vector double ang ; // direction of vector in degrees Mode mode ; // RECT or POL // private methods for setting values void set_mag ( ) ; void set_ang ( ) ; void set_x ( ) ; void

SDL视频渲染教程

。_饼干妹妹 提交于 2019-12-27 17:22:54
#include <SDL2/SDL.h> int main() { SDL_Window *window=NULL; SDL_Renderer *render=NULL; SDL_Texture *texture=NULL; SDL_Event event; SDL_Rect rect; int quit=0; //初始化环境 SDL_Init(0); //创建一个窗口 window = SDL_CreateWindow("test",200,200,900,600,SDL_WINDOW_SHOWN); if(!window) { } //创建一个渲染器 render = SDL_CreateRenderer(window,-1,0); if(!render) { } /* //设置背景色 SDL_SetRenderDrawColor(render,255,0,0,30); //SDL_RenderDrawLine(render,300,300,600,600); SDL_RenderClear(render); SDL_RenderPresent(render); // SDL_Delay(5000); //event.window */ /* 视频渲染流程: 将一幅图像的rgb数据 经过抽象为一个纹理数据 然后发送数据至显卡,然后显卡根据纹理还原一幅图像数据

C++ Vector 用法

两盒软妹~` 提交于 2019-12-27 06:29:30
在c++中,vector是一个十分有用的容器,下面对这个容器做一下总结。 1 基本操作 (1)头文件#include<vector>. (2)创建vector对象,vector<int> vec; (3)尾部插入数字:vec.push_back(a); (4)使用下标访问元素,cout<<vec[0]<<endl;记住下标是从0开始的。 (5)使用迭代器访问元素. vector<int>::iterator it; for(it=vec.begin();it!=vec.end();it++) cout<<*it<<endl; (6)插入元素: vec.insert(vec.begin()+i,a);在第i+1个元素前面插入a; (7)删除元素: vec.erase(vec.begin()+2);删除第3个元素 vec.erase(vec.begin()+i,vec.end()+j);删除区间[i,j-1];区间从0开始 (8)向量大小:vec.size(); (9)清空:vec.clear(); 2 vector的元素不仅仅可以使int,double,string,还可以是结构体,但是要注意:结构体要定义为全局的,否则会出错。下面是一段简短的程序代码: #include<stdio.h> #include<algorithm> #include<vector> #include

MFC更换背景(基于对话框)

你说的曾经没有我的故事 提交于 2019-12-27 03:41:24
最近为了赶实验自学了一点点点点的mfc,然后也是去百度了很多用于修改一些小细节的东西,先来说说怎么更换基于对话框的背景。我用的是VC++6.0,比较老了,但是实验需要,我就下着了。 步入主题吧! 1、首先你要把你想要的背景图片放在建立的对象文件夹中的res文件夹 2、而且要注意的是,这个图片格式不可以是.jpg的哦,可以用画图软件打开,然后保存的时候保存为.bmp格式,而且不能是24位的,我保存的是256色的,但是还是失真了啊,有一点点的不好看呢~ 3、VC++菜单栏的“插入”按钮,然后选择“资源”,选择第二个“Bitmap”,点击 引入 4、找到xxxxDlg.cpp打开,找到…onpaint的代码块,有if()else(),然后把else语句块里面内容改为以下代码: //CDialog::OnPaint();//要禁止这个调用 CPaintDC dc(this); CRect rect; GetClientRect(&rect); CDC dcMem; dcMem.CreateCompatibleDC(&dc); CBitmap bmpBackground; bmpBackground.LoadBitmap(IDB_BITMAP2); //IDB_Bg为刚刚载入的图片对应的ID BITMAP bitmap; bmpBackground.GetBitmap(&bitmap);

Unity计算fps

旧巷老猫 提交于 2019-12-27 03:02:49
在这里插入代码片`# if UNITY_EDITOR public class ShowFps : MonoBehaviour { public float updateInterval = .5f ; int cnt = 0 ; string stringFps ; float accum ; private void Update ( ) { accum + = Time . timeScale / Time . deltaTime ; //求平均值 updateInterval - = Time . deltaTime ; cnt ++ ; if ( updateInterval < 0 ) { double fps = accum / cnt ; updateInterval = .5f ; accum = 0 ; stringFps = $ "{fps} fps" ; cnt = 0 ; } } private void OnGUI ( ) { GUIStyle guistyle = GUIStyle . none ; guistyle . fontSize = 60 ; guistyle . normal . textColor = Color . red ; guistyle . alignment = TextAnchor . UpperLeft ; Rect rt

go语言学习-接口

家住魔仙堡 提交于 2019-12-26 22:50:37
Go语言中虽然没有传统面向对象语言中类、集成的概念,不过提供了接口的支持,可以使用接口来使用一些面向对象的特性。 在 go 语言中,的接口有下面几个特点: 可以包含0个或多个方法的签名 只定义方法的签名,不包含实现 实现接口不需要显式的声明,只需实现相应方法即可 接口的定义 定义方式如下: type Namer interface { method1(param_list) return_list method2(param_list) return_list ... } 这里的 Namer 就是接口的名字,只要符合标识符的规则即可。不过,通常约定的接口的名字最好以 er, r, able 结尾(视情况而定),这样一眼就知道它是接口。 实现接口 在 go 中实现接口很简单,不需要显式的声明实现了某个接口,想要实现某个接口,只需要实现接口中的所有方法即可。 package main import "fmt" import "math" type Shaper interface { Area() float32 Circumference() float32 } type Rect struct { Width float32 Height float32 } type Circle struct { Radius float32 } func (r Rect) Area() int

C#调用Win32 的API函数--User32.dll ----转载

纵饮孤独 提交于 2019-12-26 17:15:37
Win32的API函数是微软自己的东西,可以直接在C#中直接调用,在做WinForm时还是很有帮助的。有时候我们之直接调用Win32 的API,可以很高效的实现想要的效果。 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace WindowsAPI { class CSharp_Win32Api { #region User32.dll 函数 /// <summary> /// 该函数检索一指定窗口的客户区域或整个屏幕的显示设备上下文环境的句柄,以后可以在GDI函数中使用该句柄来在设备上下文环境中绘图。hWnd:设备上下文环境被检索的窗口的句柄 /// </summary> [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr GetDC(IntPtr hWnd); /// <summary> /// 函数释放设备上下文环境(DC)供其他应用程序使用。 /// </summary> public static extern int ReleaseDC(IntPtr