• 3.5电子书pc显示


    使用svgalib


    下载地址:
    https://launchpad.net/ubuntu/+source/svgalib/1:1.4.3-30
    svgalib_1.4.3.orig.tar.gz
    svgalib_1.4.3-30.debian.tar.gz
    svgalib_1.4.3-30.dsc

    打补丁
    tar xzf svgalib_1.4.3.orig.tar.gz
    tar xzf svgalib_1.4.3-30.debian.tar.gz
    cd svgalib-1.4.3.orig/
    for file in ../debian/patches/*.patch; do patch -p1 < $file; done
    执行for循环对于上层目录里的debian/patches/*.patch所有文件 执行 patch -p1 < $file命令

    编译安装:
    sudo make install   // 编译出错,需要安装libx86
    再 sudo make install

    下载地址
    http://packages.ubuntu.com/lucid/libx86-1

    tar xzf libx86_1.1+ds1.orig.tar.gz
    gunzip libx86_1.1+ds1-6.diff.gz
    cd libx86-1.1/
    patch -p1 < ../libx86_1.1+ds1-6.diff
    make // 出错,修改lrmi.c,添加宏, 参考561491.patch
    make
    sudo make install

    ctrl+alt+shift+f1

    #include <stdlib.h>
    #include <vga.h>
    #include <vgagl.h>
    
    /* gcc -o svgatest svgatest.c -lvga -lvgagl */
    
    int main(void)
    {
        int x, y;
        
        vga_init();
        vga_setmode(G320x200x256);
        vga_setcolor(4);
    
        for (x = 0; x < 320; x++)
            for (y = 0; y < 200; y++)
                vga_drawpixel(x, y);
    
        sleep(5);
        vga_setmode(TEXT);
    
        return EXIT_SUCCESS;
    }

    sudo ./svgatest

    如果缺少动态链接库

    http://www.cnblogs.com/CZM-/p/5342427.html

    使用调色板

    #include <vgagl.h>
    
     gl_setpalettecolor(4, 0xE7>>2, 0xDB>>2, 0xB5>>2);   /* 0xE7DBB5  */ /* ·º»ÆµÄÖ½ */

    gcc -o svgatest svgatest.c  -lvga -lvgagl

    开始写pc电子书显示程序

    修改Makefile

    不用交叉编译

    CROSSCOMPILE :=

    添加库

    all: $(OBJS)
            $(CC) $(LDFLAGS) -o show_file $^ -lvga -lvgagl

    指定头文件目录

    CFLAGS  += -I$(PWD)/include -I /usr/include/freetype2/

      display/crt.o                 

    #include <config.h>
    #include <disp_manager.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <sys/ioctl.h>
    #include <sys/mman.h>
    #include <linux/fb.h>
    #include <string.h>
    
    #include <stdlib.h>
    #include <vga.h>
    #include <vgagl.h>
    
    static int CRTDeviceInit(void);
    static int CRTShowPixel(int iX, int iY, unsigned int dwColor);
    static int CRTCleanScreen(unsigned int dwBackColor);
    static int CRTDeviceExit(void);
    
    
    static T_DispOpr g_tCRTOpr = {
        /* ÏÔʾÆÁĬÈÏÃû×Ö "crt*/
        .name        = "crt",    
        .DeviceInit  = CRTDeviceInit,
        .DeviceExit  = CRTDeviceExit,
        .ShowPixel   = CRTShowPixel,
        .CleanScreen = CRTCleanScreen,
    };
    
    static int CRTDeviceInit(void)
    {
        vga_init();
        vga_setmode(G320x200x256);
        g_tCRTOpr.iXres = 320;
        g_tCRTOpr.iYres = 200;
        g_tCRTOpr.iBpp = 8;
        return 0;
    }
    
    static int CRTDeviceExit(void)
    {
        vga_setmode(TEXT);
    
        return EXIT_SUCCESS;
    }
    
    
    static int CRTShowPixel(int iX, int iY, unsigned int dwColor)
    {
        int iRed,iGreen,iBlue;
    
        iRed   = (dwColor >> 16) & (0xff);
        iGreen = (dwColor >> 8) & (0xff);
        iBlue  = (dwColor >> 0) & (0xff);
    
        gl_setpalettecolor(5, iRed>>2, iGreen>>2, iBlue>>2);   /* 0xE7DBB5  */ /* ·º»ÆµÄÖ½ */
        vga_setcolor(5);
    
        vga_drawpixel(iX, iY);
        return 0;
    }
    
    static int CRTCleanScreen(unsigned int dwBackColor)
    {
        int iX;
        int iY;
        int iRed,iGreen,iBlue;
    
        iRed   = (dwBackColor >> 16) & (0xff);
        iGreen = (dwBackColor >> 8) & (0xff);
        iBlue  = (dwBackColor >> 0) & (0xff);
    
        gl_setpalettecolor(4, iRed>>2, iGreen>>2, iBlue>>2);   /* 0xE7DBB5  */ /* ·º»ÆµÄÖ½ */
        vga_setcolor(4);
    
        for (iX = 0; iX < 320; iX++)
            for (iY = 0; iY < 200; iY++)
                vga_drawpixel(iX, iY);
        return 0;
    }
    
    int CRTInit(void)
    {
        return RegisterDispOpr(&g_tCRTOpr);
    }

    ./show_file -s 16  -d crt -h HZK16   -f ./MSYH.TTF daomubiji.txt

  • 相关阅读:
    关于深拷贝和浅拷贝的理解
    Oracle数据库入门
    单例模式入门
    oracle存储过程 (还没动手实践、剩余内容找时间在处理、游标还没接触)
    Oracle用户名及默认密码
    oracle数据库怎么创建数据库实例
    Java 强、弱、软、虚,你属于哪一种?
    内存溢出和内存泄漏的区别
    aop中execution 表达式
    JPA 中@Enumerated
  • 原文地址:https://www.cnblogs.com/CZM-/p/5342933.html
Copyright © 2020-2023  润新知