C++将一个图片显示到窗口里面
来源:互联网 发布:激光雕刻用什么软件 编辑:程序博客网 时间:2024/05/23 02:04
// Test2.cpp : 定义控制台应用程序的入口点。
//
#pragma comment(lib,"user32")
#pragma comment(lib,"gdi32")
#include "stdafx.h"
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
#include <atlimage.h>
HWND WINAPI GetConsoleWindow();
void HideTheCursor() {
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (GetConsoleCursorInfo(hStdOut, &cciCursor)) {
cciCursor.bVisible = FALSE;
SetConsoleCursorInfo(hStdOut, &cciCursor);
}
}
void ShowTheCursor() {
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (GetConsoleCursorInfo(hStdOut, &cciCursor)) {
cciCursor.bVisible = TRUE;
SetConsoleCursorInfo(hStdOut, &cciCursor);
}
}
int main() {
HWND hwnd;
HDC hdc;
HFONT hfont;
HBITMAP hbm;
HDC hdcBits;
BITMAP bm;
CImage Image;
system("color F0");
system("cls");
HideTheCursor();
hwnd = GetConsoleWindow();
hdc = GetDC(hwnd);
Image.Load(L"1.jpg");
hbm=Image.Detach();
//hbm=LoadImage(0,"C:\\Windows\\1.jpg",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
if (hbm) {
hdcBits = CreateCompatibleDC(hdc);
GetObject (hbm, sizeof(BITMAP), &bm);
SelectObject(hdcBits,hbm);
BitBlt(hdc,20,10,bm.bmWidth, bm.bmHeight,hdcBits,0,0,SRCCOPY);
BitBlt(hdc,20,10,bm.bmWidth, bm.bmHeight,hdcBits,0,0,SRCCOPY);
DeleteDC(hdcBits);
DeleteObject(hbm);
}
hfont = CreateFont(24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L"华文楷体");
SelectObject(hdc,hfont);
SetTextColor(hdc,RGB(255,255,255));
SetBkMode(hdc,TRANSPARENT);
TextOut(hdc,210,30,L"这个背景是泡泡",14);
DeleteObject(hfont);
ReleaseDC(hwnd,hdc);
getch();
system("color 07");
system("cls");
ShowTheCursor();
return 0;
}
//
#pragma comment(lib,"user32")
#pragma comment(lib,"gdi32")
#include "stdafx.h"
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
#include <atlimage.h>
HWND WINAPI GetConsoleWindow();
void HideTheCursor() {
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (GetConsoleCursorInfo(hStdOut, &cciCursor)) {
cciCursor.bVisible = FALSE;
SetConsoleCursorInfo(hStdOut, &cciCursor);
}
}
void ShowTheCursor() {
CONSOLE_CURSOR_INFO cciCursor;
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (GetConsoleCursorInfo(hStdOut, &cciCursor)) {
cciCursor.bVisible = TRUE;
SetConsoleCursorInfo(hStdOut, &cciCursor);
}
}
int main() {
HWND hwnd;
HDC hdc;
HFONT hfont;
HBITMAP hbm;
HDC hdcBits;
BITMAP bm;
CImage Image;
system("color F0");
system("cls");
HideTheCursor();
hwnd = GetConsoleWindow();
hdc = GetDC(hwnd);
Image.Load(L"1.jpg");
hbm=Image.Detach();
//hbm=LoadImage(0,"C:\\Windows\\1.jpg",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
if (hbm) {
hdcBits = CreateCompatibleDC(hdc);
GetObject (hbm, sizeof(BITMAP), &bm);
SelectObject(hdcBits,hbm);
BitBlt(hdc,20,10,bm.bmWidth, bm.bmHeight,hdcBits,0,0,SRCCOPY);
BitBlt(hdc,20,10,bm.bmWidth, bm.bmHeight,hdcBits,0,0,SRCCOPY);
DeleteDC(hdcBits);
DeleteObject(hbm);
}
hfont = CreateFont(24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L"华文楷体");
SelectObject(hdc,hfont);
SetTextColor(hdc,RGB(255,255,255));
SetBkMode(hdc,TRANSPARENT);
TextOut(hdc,210,30,L"这个背景是泡泡",14);
DeleteObject(hfont);
ReleaseDC(hwnd,hdc);
getch();
system("color 07");
system("cls");
ShowTheCursor();
return 0;
}
0 0
- C++将一个图片显示到窗口里面
- opencv在一个窗口里面显示多张图片
- 将一个窗口显示到最前面的源代码
- 将图片保存到RMS里面
- 终于搞明白如何将一个JPanel放置到JScrollPane里面并显示滚动条了
- c语言初步经典题16---将一个文件的内容复制到另一个文件里面
- 读取BMP图片并显示到窗口.
- OpenCV一个窗口显示多张图片
- 一个窗口显示多幅图片
- OpenCV一个窗口显示多张图片
- OpenCV一个窗口显示多张图片
- opencv2 一个窗口显示多幅图片
- OpenCV 一个窗口显示多个图片
- 在服务里面弹出一个窗口到用户的桌面上
- Android——将图片加入到系统相册里面
- 将各类图片显示到桌面
- 将网上图片显示到 View 上
- 将图片显示在一个控件上
- 模块对于 safeseh 映像是不安全的
- 数据库的创建和sql语句增删改查
- 统计手机流量
- Redmine
- 局部极大值
- C++将一个图片显示到窗口里面
- Python集合(set)类型的操作
- c++11 函数内部返回对象使用move语义的最佳实践
- 记录下自己拙计的算法之旅 LeetCode Rotate Array
- 函数后面加throw关键字的含义
- 单链表
- 深度学习方法:受限玻尔兹曼机RBM(二)网络模型
- JavaScript规范
- css3中边框的4种样式