当前位置: 首页 > news >正文

教育类的网站案例微信公众号不能上传wordpress

教育类的网站案例,微信公众号不能上传wordpress,宣传山西的网页设计,公司网站制作步骤加载BMP 1.使用SDL_init初始化SDL库 2.使用SDL_CreateWindow创建一个窗口 3.使用SDL_GetWindowSurface获取创建窗口的surface 4.使用SDL_LoadBMP加载一张BMP图片 5.使用SDL_BlitSurface将加载的bmp surface拷贝到窗口的surface 6.使用SDL_UpdateWindowSurface更新到窗口 …

加载BMP

1.使用SDL_init初始化SDL库

2.使用SDL_CreateWindow创建一个窗口

3.使用SDL_GetWindowSurface获取创建窗口的surface

4.使用SDL_LoadBMP加载一张BMP图片

5.使用SDL_BlitSurface将加载的bmp surface拷贝到窗口的surface

6.使用SDL_UpdateWindowSurface更新到窗口

7.使用SDL_FreeSurface释放申请的空间

8.使用SDL_DestroyWindow销毁窗口

9.使用SDL_Quit释放SDL库

以下时完整代码

#include <iostream>
#include <sdl.h>const int SCREEN_WIDTH = 640;
const int  SCREEN_HEIGHT = 480;SDL_Window* gWindow = nullptr;
SDL_Surface* gScreenSurface = nullptr;
SDL_Surface* gHelloWorld = nullptr;bool init()
{bool success = true;if (SDL_Init(SDL_INIT_VIDEO) < 0){printf("SDL could not initialize!SDL Error:%s\n", SDL_GetError());success = false;}else{//create windowgWindow = SDL_CreateWindow("SDL tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);if (gWindow == nullptr){printf("window could not created!SDL_Error:%s\n", SDL_GetError());success = false;}else{//get window surfacegScreenSurface = SDL_GetWindowSurface(gWindow);}}return success;
}bool loadMedia()
{//loading success flagbool success = true;//load splash imagegHelloWorld = SDL_LoadBMP("../BMP2.bmp");if (gWindow == nullptr){printf("unable to load image!SDL_ERROR%s\n",SDL_GetError());success = false;}return success;
}void close()
{SDL_FreeSurface(gHelloWorld);gHelloWorld = NULL;SDL_DestroyWindow(gWindow);gWindow = NULL;SDL_Quit();}int main(int argc, char* args[])
{if (!init()){printf("failed to initialize!\n");}else{//load mediaif (!loadMedia()){printf("failed to load media!\n");}else{SDL_BlitSurface(gHelloWorld, nullptr, gScreenSurface, nullptr);//update the surfaceSDL_UpdateWindowSurface(gWindow);SDL_Event e;bool quit = false;while (quit == false){while (SDL_PollEvent(&e)){if (e.type == SDL_QUIT)quit = true;}}}}close();return 0;
}

加载PNG

由于默认的SDL库只能加载BMP格式的图片,如果需要加载png等其他格式的图片,需要下载一个扩展库SDL_image​​​​​​

这里我们下载SDL2_image-devel-2.6.3-VC.zipSDL_image​​​​​​

 加载步骤与加载BMP步骤差不多,这里需要注意以下几点

1.需要使用IMG_Init初始化iamge库

2. 使用IMG_Load加载png图片(之前使用SDL_LoadBMP加载BMP)

3.使用IMG_Quit释放image库

以下是完整代码

#include <iostream>
#include <sdl.h>
#include <sdl_image.h>
#include <string>using namespace std;const int SCREEN_WIDTH = 640;
const int  SCREEN_HEIGHT = 480;SDL_Surface* loadSurface(std::string path);SDL_Window* gWindow = nullptr;SDL_Surface* gScreenSurface = nullptr;SDL_Surface* gPNGSurface = nullptr;bool init()
{bool success = true;//initialize SDLif (SDL_Init(SDL_INIT_VIDEO) < 0){printf("SDL_ERROR:%s\n", SDL_GetError());success = false;}else{//create windowgWindow = SDL_CreateWindow("SDL load PNG", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );if (gWindow == nullptr){printf("SDL_ERROR:%s\n", SDL_GetError());success = false;}else{//initialize PNG loadingint imgFlag = IMG_INIT_PNG;if (!(IMG_Init(imgFlag) & imgFlag)){printf("SDL_IMAGE could not initialize!SDL_IMAGE ERROR: %s\n", IMG_GetError());success = false;}else{//get window surfacegScreenSurface = SDL_GetWindowSurface(gWindow);}}}return success;
}SDL_Surface* loadSurface(string path)
{SDL_Surface* optimizedSurface = nullptr;//load image at specified pathSDL_Surface* loadSurface = IMG_Load(path.c_str());if (loadSurface == nullptr){printf("load image error: %s\n", IMG_GetError());}else{//convert surface to screen formatoptimizedSurface = SDL_ConvertSurface(loadSurface, gScreenSurface->format, 0);if (optimizedSurface == nullptr){printf("unable to optimize image: %s\n", SDL_GetError());}//get rid of old loaded surfaceSDL_FreeSurface(loadSurface);}return optimizedSurface;
}bool loadMedia()
{//Loading success flagbool success = true;//Load PNG surfacegPNGSurface = loadSurface("../picture/loaded.png");if (gPNGSurface == NULL){printf("Failed to load PNG image!\n");success = false;}return success;
}void close()
{SDL_FreeSurface(gPNGSurface);gPNGSurface = nullptr;SDL_DestroyWindow(gWindow);gWindow = nullptr;IMG_Quit();SDL_Quit();
}int main(int argc, char* argv[])
{if (!init()){printf("Failed to initialize!\n");}else{//Load mediaif (!loadMedia()){printf("Failed to load media!\n");}else{//Main loop flagbool quit = false;//Event handlerSDL_Event e;//While application is runningwhile (!quit){//Handle events on queuewhile (SDL_PollEvent(&e) != 0){//User requests quitif (e.type == SDL_QUIT){quit = true;}}//Apply the PNG imageSDL_BlitSurface(gPNGSurface, NULL, gScreenSurface, NULL);//Update the surfaceSDL_UpdateWindowSurface(gWindow);}}}//Free resources and close SDLclose();return 0;
}

http://www.yayakq.cn/news/25108/

相关文章:

  • 仿站模板肇庆cms建站系统
  • 网站文章页图片不显示360平台推广
  • 营销型网站建设对比分析dede世界杯网站模板
  • 西宁网站建设官网如何线上注册公司
  • ps做网站大小尺寸百度app关键词优化
  • 教务系统网站开发方法js网站模板
  • 网站底部怎么修改广州建造网站公司
  • 页面设计好看的网站seo搜索引擎优化怎么优化
  • 手机网站开发成本厦门小程序开发
  • WordPress能够做小说网站吗wordpress字体路径设置
  • ui设计 国外网站wordpress文章首页
  • 设计的素材网站有哪些视频 wordpress 主题
  • 网站维护和建设工作范围建筑网站建设赏析
  • emlog建站教程家具企业网站模板
  • xampp做的网站能搜索吗图片自动导入wordpress
  • 湖南手机响应式网站建设企业asp.net网站开发教程下载
  • 网站统计关键词学网络工程师
  • 服装网站ui设计wordpress cpu突然
  • 花店网站开发设计的项目结构厦门做企业网站多少钱
  • 网站建设作业过程贵阳花果园网站建设
  • 做带v头像的网站南京宣传片拍摄制作公司
  • 网站用户细分苏州网站设计公司兴田德润在哪里呢
  • 曲周县建设局网站蛙蛙写作网站
  • 烟台电子商务网站怎样判断网站的好坏
  • 济南英文网站建设药品在网站上做标签有哪些分类
  • 设计企业网站哪家好聊城建设路小学网站
  • 建设银行杭州分行网站加盟做地方门户网站
  • 北仑网站网页建设十大开源软件
  • 济南高端网站制作公司关于网站建设的报告
  • 网站可以查出在哪里做的吗西安创意网站建设