资深光能
不可能的,我以前为了它浪费了很长时间
但依然没有答案
百度上也搜不到
高级守护
C++是在C语言的基础上开发的一种通用编程语言,应用广泛。C++支持多种编程范式 --面向对象编程、泛型编程和过程化编程。
办法:CPaintDC dc(this);//建立设备描述表
HBITMAP hbitmap=
::LoadBitmap(::AfxGetInstanceHandle();
MAKEINTRESOURCE(IDB_MYBMP));//这里的位图是集成在程序里的,所以位图要加入进工程。这里的位图名IDB_MYBMP。
HDC hMemDC=::CreateCompatibleDC(NULL);//建立内存描述表
SelectObject(hMemDC,HBITMAP);//<<--导出图片
::StretchBlt(dc.m_hDC,
50,
50,
100,
100,
hMemDC,
0,
0,
250,
250,
SRCCOPY);//--结束导出>>
::DeleteDC(hMemDC);//删除建立的对象
::DeleteIbject(hbitmap);
贾天宇在2019-08-19 16:37:33追加了内容
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int nx = 200;
int ny = 100;
ofstream outfile( "mytest.txt", ios_base::out);
outfile << "P3\n" << nx << " " << ny << "\n255\n";
std::cout << "P3\n" << nx << " " << ny << "\n255\n";
for (int j = ny-1; j >= 0; j--)
{
for (int i = 0; i < nx; i++)
{
float r = float(i) / float(nx);
float g = float(j) / float(ny);
float b = 0.2;
int ir = int (255.99*r);
int ig = int (255.99*g);
int ib = int (255.99*b);
outfile << ir << " " << ig << " " << ib << "\n";
std::cout << ir << " " << ig << " " << ib << "\n";
}
}
}
将结果输出到文件
#include <fstream>
ofstream outfile( "mytest.txt", ios_base::out);
outfile << "P3\n" << nx << " " << ny << "\n255\n";
outfile << ir << " " << ig << " " << ib << "\n";