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

做网站怎么找公司去除痘痘怎么有效果

做网站怎么找公司,去除痘痘怎么有效果,哈尔滨网络公司代理商,企业网站建设的平台Linux截图工具gsnap移植arm平台过程记录 最近工作中一款新产品开发接近尾声,需要写文档截图产品图形,找了一款开源的Linux截屏工具gsnap,将其移植到ARM产品中,这里记录一下移植过程。 gsnap 这个工具源代码就是一个C语言源文件&a…

Linux截图工具gsnap移植arm平台过程记录

最近工作中一款新产品开发接近尾声,需要写文档截图产品图形,找了一款开源的Linux截屏工具gsnap,将其移植到ARM产品中,这里记录一下移植过程。

gsnap

这个工具源代码就是一个C语言源文件:gsnap.c,感谢作者的分享。

/** File:    gsnap.c* Author:  Li XianJing <xianjimli@hotmail.com>* Brief:   snap the linux mobile device screen.** Copyright (c) 2009  Li XianJing <xianjimli@hotmail.com>** Licensed under the Academic Free License version 2.1** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2 of the License, or* (at your option) any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the* GNU General Public License for more details.** You should have received a copy of the GNU General Public License* along with this program; if not, write to the Free Software* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*//** History:* ================================================================* 2009-08-20 Li XianJing <xianjimli@hotmail.com> created* 2011-02-28 Li XianJing <xianjimli@hotmail.com> suppport RGB888 framebuffer.* 2011-04-09 Li XianJing <xianjimli@hotmail.com> merge figofuture's png output.* 	ref: http://blog.chinaunix.net/space.php?uid=15059847&do=blog&cuid=2040565**/#include <png.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <jpeglib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <linux/fb.h>
#include <linux/kd.h>struct _FBInfo;
typedef struct _FBInfo FBInfo;
typedef int (*UnpackPixel)(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b);struct _FBInfo
{int fd;UnpackPixel unpack;unsigned char *bits;struct fb_fix_screeninfo fi;struct fb_var_screeninfo vi;
};#define fb_width(fb)  ((fb)->vi.xres)
#define fb_height(fb) ((fb)->vi.yres)
#define fb_bpp(fb)    ((fb)->vi.bits_per_pixel>>3)
#define fb_size(fb)   ((fb)->vi.xres * (fb)->vi.yres * fb_bpp(fb))static int fb_unpack_rgb565(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b)
{unsigned short color = *(unsigned short*)pixel;*r = ((color >> 11) & 0xff) << 3;*g = ((color >> 5) & 0xff)  << 2;*b = (color & 0xff )<< 3;return 0;
}static int fb_unpack_rgb24(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b)
{*r = pixel[fb->vi.red.offset>>3];*g = pixel[fb->vi.green.offset>>3];*b = pixel[fb->vi.blue.offset>>3];return 0;
}static int fb_unpack_argb32(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b)
{*r = pixel[fb->vi.red.offset>>3];*g = pixel[fb->vi.green.offset>>3];*b = pixel[fb->vi.blue.offset>>3];return 0;
}static int fb_unpack_none(FBInfo* fb, unsigned char* pixel, unsigned char* r, unsigned char* g, unsigned char* b)
{*r = *g = *b = 0;return 0;
}static void set_pixel_unpacker(FBInfo* fb)
{if(fb_bpp(fb) == 2){fb->unpack = fb_unpack_rgb565;}else if(fb_bpp(fb) == 3){fb->unpack = fb_unpack_rgb24;}else if(fb_bpp(fb) == 4){fb->unpack = fb_unpack_argb32;}else{fb->unpack = fb_unpack_none;printf("%s: not supported format.\n", __func__);}return;
}static int fb_open(FBInfo* fb, const char* fbfilename)
{fb->fd = open(fbfilename, O_RDWR);if (fb->fd < 0){fprintf(stderr, "can't open %s\n", fbfilename);return -1;}if (ioctl(fb->fd, FBIOGET_FSCREENINFO, &fb->fi) < 0)goto fail;if (ioctl(fb->fd, FBIOGET_VSCREENINFO, &fb->vi) < 0)goto fail;fb->bits = mmap(0, fb_size(fb), PROT_READ | PROT_WRITE, MAP_SHARED, fb->fd, 0);if (fb->bits == MAP_FAILED)goto fail;printf("---------------framebuffer---------------\n");printf("%s: \n  width : %8d\n  height: %8d\n  bpp   : %8d\n  r(%2d, %2d)\n  g(%2d, %2d)\n  b(%2d, %2d)\n",fbfilename, fb_width(fb), fb_height(fb), fb_bpp(fb), fb->vi.red.offset, fb->vi.red.length,fb->vi.green.offset, fb->vi.green.length,fb->vi.blue.offset, fb->vi.blue.length);printf("-----------------------------------------\n");set_pixel_unpacker(fb);return 0;fail:printf("%s is not a framebuffer.\n", fbfilename);close(fb->fd);return -1;
}static void fb_close(FBInfo* fb)
{munmap(fb->bits, fb_size(fb));close(fb->fd);return;
}static int snap2jpg(const char * filename, int quality, FBInfo* fb)
{int row_stride = 0; FILE * outfile = NULL;JSAMPROW row_pointer[1] = {0};struct jpeg_error_mgr jerr;struct jpeg_compress_struct cinfo;memset(&jerr, 0x00, sizeof(jerr));memset(&cinfo, 0x00, sizeof(cinfo));cinfo.err = jpeg_std_error(&jerr);jpeg_create_compress(&cinfo);if ((outfile = fopen(filename, "wb+")) == NULL) {fprintf(stderr, "can't open %s\n", filename);return -1;}jpeg_stdio_dest(&cinfo, outfile);cinfo.image_width = fb_width(fb);cinfo.image_height = fb_height(fb);cinfo.input_components = 3;cinfo.in_color_space = JCS_RGB;jpeg_set_defaults(&cinfo);jpeg_set_quality(&cinfo, quality, TRUE);jpeg_start_compress(&cinfo, TRUE);row_stride = fb_width(fb) * 2;JSAMPLE* image_buffer = malloc(3 * fb_width(fb));while (cinfo.next_scanline < cinfo.image_height) {int i = 0;int offset = 0;unsigned char* line = fb->bits + cinfo.next_scanline * fb_width(fb) * fb_bpp(fb);for(i = 0; i < fb_width(fb); i++, offset += 3, line += fb_bpp(fb)){fb->unpack(fb, line, image_buffer+offset, image_buffer + offset + 1, image_buffer + offset + 2);}row_pointer[0] = image_buffer;(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);}jpeg_finish_compress(&cinfo);fclose(outfile);jpeg_destroy_compress(&cinfo);return 0;
}//Ref: http://blog.chinaunix.net/space.php?uid=15059847&do=blog&cuid=2040565
static int snap2png(const char * filename, int quality, FBInfo* fb)
{FILE *outfile;if ((outfile = fopen(filename, "wb+")) == NULL){fprintf(stderr, "can't open %s\n", filename);return -1;}/* prepare the standard PNG structures */png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0);png_infop info_ptr = png_create_info_struct(png_ptr);/* setjmp() must be called in every function that calls a PNG-reading libpng function */if (setjmp(png_jmpbuf(png_ptr))){png_destroy_write_struct(&png_ptr, &info_ptr);fclose(outfile);return -1;}/* initialize the png structure */png_init_io(png_ptr, outfile);//int width = 0;int height = 0;int bit_depth = 8;int color_type = PNG_COLOR_TYPE_RGB;int interlace = 0;width = fb_width(fb);height = fb_height(fb);png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type,(!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7,PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);/* write the file header information */png_write_info(png_ptr, info_ptr);png_bytep row_pointers[height];png_byte* image_buffer = malloc(3 * width);int i = 0;int j = 0;unsigned char* line = NULL;for( ; i < height; i++ ){line = (char*)fb->bits + i * width * fb_bpp(fb);for(j = 0; j < width; j++, line += fb_bpp(fb)){int offset = j * 3;fb->unpack(fb, line, image_buffer+offset, image_buffer+offset+1, image_buffer+offset+2);}row_pointers[i] = image_buffer;png_write_rows(png_ptr, &row_pointers[i], 1);}png_destroy_write_struct(&png_ptr, &info_ptr);fclose(outfile);return 0;}int main(int argc, char* argv[])
{FBInfo fb;const char* filename   = NULL;const char* fbfilename = NULL;if(argc != 3){printf("\nUsage: %s [jpeg|png file] [framebuffer dev]\n", argv[0]);printf("Example: %s fb.jpg /dev/fb0\n", argv[0]);printf("-----------------------------------------\n");printf("Powered by broncho(www.broncho.cn)\n\n");return 0;}filename   = argv[1];fbfilename = argv[2];memset(&fb, 0x00, sizeof(fb));if (fb_open(&fb, fbfilename) == 0){if(strstr(filename, ".png") != NULL){snap2png(filename, 100, &fb);}else{snap2jpg(filename, 100, &fb);}fb_close(&fb);}return 0;
}

gsnap需要两个依赖库libjpeg和libPng。而libPng还要依赖Zlib库。关于Zlib库的交叉编译请参考我这篇文档不再赘述zlib库的交叉编译记录

编译libjpeg库

从官网ijg.org下载源码
在Linux主机中解压后进入解压目录jpeg-9f。
运行autotools的配置命令进行配置后编译。

./configure --host=arm-linux-gnueabihf --prefix=/root/jpeg-9f/arm_install
make && make install

–host参数是指定编译器,我已经将我的ARM交叉编译工具链目录设置在了系统目录中,所以这里只需指定编译器前缀就行。
–prefix参数是指定编译后的安装目录,编译后make工具会将生成的编译文件和头文件目录拷贝到这个指定目录中。

编译libpng库

从SourceForge中下载源代码,我下载的是libpng-1.6.43.tar.gz
在Linux主机中解压后进入解压目录libpng-1.6.43。
注意,因为需要zlib库,故先配置一下几个编译变量。

export LDFLAGS="-L/root/zlib/arm_install/lib"
export CFLAGS="-I/root/zlib/arm_install/include"
export CPPFLAGS="-I/root/zlib/arm_install/include"

LDFLAGS是编译器搜索库文件路径变量。
CFLAGS是编译器C语言编译选项变量,这里是设置zlib库的头文件位置。
CPPFLAGS是编译器预处理器选项变量,这里是设置zlib库的头文件位置。
设置环境变量完毕后,运行配置命令进行配置后编译。

./configure --host=arm-linux-gnueabihf --prefix=/root/libpng-1.6.43/arm_install
make && make install

编译gsnap

几个库都准备好了,进入gsnap目录,将gsnap.c文件拷贝进来,进行编译。编译命令如下:

arm-linux-gnueabihf-gcc -o gsnap gsnap.c \
-L/root/jpeg-9f/arm_install/lib \
-L/root/libpng-1.6.43/arm_install/lib \
-L/root/zlib/arm_install/lib \
-I/root/jpeg-9f/arm_install/include \
-I/root/libpng-1.6.43/arm_install/include \
-I/root/zlib/arm_install/include \
-static -ljpeg -lpng -lz -lm

此命令是用静态链接方式,编译后不再需要几个库文件,单独使用编译后的gsnap文件即可。
将编译目标文件gsnap拷贝到arm板子中。
运行命令:

gsnap test.jpg /dev/fb0

这样就捕获了当前屏幕的截图文件test.jpg。

如果文章对您有用,请随手点个赞,谢谢!^_^


文章转载自:
http://molluscicide.ncmj.cn
http://silicize.ncmj.cn
http://laticifer.ncmj.cn
http://flood.ncmj.cn
http://academician.ncmj.cn
http://promotive.ncmj.cn
http://rubout.ncmj.cn
http://sappan.ncmj.cn
http://mariupol.ncmj.cn
http://lilac.ncmj.cn
http://acrosin.ncmj.cn
http://archiepiscopal.ncmj.cn
http://silesia.ncmj.cn
http://aerostatical.ncmj.cn
http://blacktop.ncmj.cn
http://jota.ncmj.cn
http://camera.ncmj.cn
http://whitethorn.ncmj.cn
http://tenemental.ncmj.cn
http://fluidonics.ncmj.cn
http://absquatulater.ncmj.cn
http://yielding.ncmj.cn
http://collage.ncmj.cn
http://outspend.ncmj.cn
http://polyhalite.ncmj.cn
http://impersonalize.ncmj.cn
http://phylloclade.ncmj.cn
http://fellagha.ncmj.cn
http://dissociative.ncmj.cn
http://arsenotherapy.ncmj.cn
http://multifarious.ncmj.cn
http://imbark.ncmj.cn
http://qi.ncmj.cn
http://scilicet.ncmj.cn
http://frumpish.ncmj.cn
http://acetaldehyde.ncmj.cn
http://properly.ncmj.cn
http://encomiastic.ncmj.cn
http://cybele.ncmj.cn
http://gustav.ncmj.cn
http://guess.ncmj.cn
http://meow.ncmj.cn
http://filch.ncmj.cn
http://cadwallader.ncmj.cn
http://clowder.ncmj.cn
http://euphory.ncmj.cn
http://metallike.ncmj.cn
http://osmeterium.ncmj.cn
http://moundsman.ncmj.cn
http://strook.ncmj.cn
http://buddle.ncmj.cn
http://flightless.ncmj.cn
http://yeuk.ncmj.cn
http://embassage.ncmj.cn
http://leukocytotic.ncmj.cn
http://chantage.ncmj.cn
http://syllabus.ncmj.cn
http://bra.ncmj.cn
http://microcosmic.ncmj.cn
http://triptyque.ncmj.cn
http://seismogram.ncmj.cn
http://botargo.ncmj.cn
http://trouty.ncmj.cn
http://greffier.ncmj.cn
http://possible.ncmj.cn
http://hypereutectic.ncmj.cn
http://paragrapher.ncmj.cn
http://sendmail.ncmj.cn
http://zoosperm.ncmj.cn
http://bootable.ncmj.cn
http://curfewed.ncmj.cn
http://somaliland.ncmj.cn
http://jawbreaker.ncmj.cn
http://ruapehu.ncmj.cn
http://reflate.ncmj.cn
http://frail.ncmj.cn
http://stakhanovite.ncmj.cn
http://jawlike.ncmj.cn
http://dinghy.ncmj.cn
http://mennonite.ncmj.cn
http://cambric.ncmj.cn
http://pigling.ncmj.cn
http://tippytoe.ncmj.cn
http://calamus.ncmj.cn
http://gadabout.ncmj.cn
http://diplomatic.ncmj.cn
http://delocalize.ncmj.cn
http://adieux.ncmj.cn
http://osrd.ncmj.cn
http://dogtrot.ncmj.cn
http://obscene.ncmj.cn
http://byronic.ncmj.cn
http://antemundane.ncmj.cn
http://optimum.ncmj.cn
http://pensel.ncmj.cn
http://scrimshander.ncmj.cn
http://manuscript.ncmj.cn
http://premortuary.ncmj.cn
http://bled.ncmj.cn
http://upstroke.ncmj.cn
http://www.dt0577.cn/news/79985.html

相关文章:

  • 菠菜网站开发哪家好郑州网络推广报价
  • 专注徐州网站建设常州网站关键词推广
  • 外贸网站推广上海seo搜索优化待遇
  • 信阳市工程建设信息网站郑州seo优化培训
  • 注册网站域名需要什么小说网站排名前十
  • 莞城注册能源公司网上注册流程seo优化员
  • 东莞网站建设电镀挂具天津百度网站排名优化
  • 建设食品商购网站百度总部客服电话
  • 怎么看网站的访问量百度seo推广优化
  • wordpress 视频站模版网页搜索引擎大全
  • 昆山外贸网站建设推广seo搜索引擎优化视频
  • 营销网站建设企划案例淘宝搜索关键词排名
  • 宝安做棋牌网站建设哪家技术好seo模拟点击工具
  • 中国优秀设计网站东莞seo托管
  • 给女朋友做情侣网站的程序员seo搜索工具栏
  • 外贸cms建站昆明seo网站管理
  • 程序开发公司名大全专业百度seo排名优化
  • 网站备案承诺书怎么写网站加速
  • 滨海做网站哪家最好ip域名解析查询
  • asp网站验证码不显示临沂百度代理公司有几个
  • 网站没有被收录肥城市区seo关键词排名
  • wordpress删除站点百度推广怎么做效果好
  • 做网站模板出售类网站怎么样模板建站代理
  • 已有网站做app需要多少钱湖南网站网络推广哪家奿
  • c 做网站怎么显示歌词seo赚钱项目
  • 单位如何做网站宣传全球外贸采购网
  • 广州房地产网站建设方案微信引流推广精准粉
  • wordpress 中型网站上海最新新闻事件今天国内
  • wordpress网站语言包赣州seo顾问
  • 青岛开发区网站建设公司竞价外包托管费用