我用hzk16大部分没有问题,但是生僻字不行,据说gbk可以,但是读取机内码的方式不一样啊,应该怎么获得机内码和点阵呢

解决方案 »

  1.   

    可以自己来转字,把字打到picture里去,然后取出字模来
      

  2.   

    http://download.csdn.net/source/2180241
    #include <windows.h>
    #include <stdio.h>int main() {
        const DWORD uWidth = 18 + 17 * 256, uHeight = 18 + 17 * 128;    PBITMAPINFO pbmi = (PBITMAPINFO) LocalAlloc (LPTR, sizeof (BITMAPINFOHEADER) + sizeof (RGBQUAD) * 2);
        pbmi->bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
        pbmi->bmiHeader.biWidth = uWidth;
        pbmi->bmiHeader.biHeight = uHeight;
        pbmi->bmiHeader.biPlanes = 1;
        pbmi->bmiHeader.biBitCount = 1;
        pbmi->bmiHeader.biSizeImage = ((uWidth + 31) & ~31) / 8 * uHeight;
        pbmi->bmiColors[0].rgbBlue = 0;
        pbmi->bmiColors[0].rgbGreen = 0;
        pbmi->bmiColors[0].rgbRed = 0;
        pbmi->bmiColors[1].rgbBlue = 255;
        pbmi->bmiColors[1].rgbGreen = 255;
        pbmi->bmiColors[1].rgbRed = 255;    HDC hDC = CreateCompatibleDC (0);
        void * pvBits;
        HBITMAP hBitmap = CreateDIBSection (hDC, pbmi, 0, &pvBits, NULL, 0);
        SelectObject (hDC, hBitmap);
        HFONT hFont = CreateFont (16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "宋体");
        SelectObject (hDC, hFont);
        BitBlt (hDC, 0, 0, uWidth, uHeight, NULL, 0, 0, WHITENESS);    char c[4];
        int i, j;
        for (i = 128; i < 256; i++) {
            sprintf (c, "%02X", i);
            TextOut (hDC, 1, (i - 127) * 17 + 1, c, 2);
        }
        for (j = 0; j < 256; j++) {
            sprintf (c, "%02X", j);
            TextOut (hDC, (j + 1)* 17 + 1, 1, c, 2);
        }
        for (i = 128; i < 256; i++) {
            for (j = 0; j < 256; j++) {
                c[0] = (char) i;
                c[1] = (char) j;
                TextOut (hDC, (j + 1) * 17 + 1, (i - 127) * 17 + 1, c, 2);
            }
        }
        for (i = 0; i < 130; i++) {
            MoveToEx (hDC, 0, i * 17, NULL);
            LineTo (hDC, uWidth, i * 17);
        }
        for (j = 0; j < 258; j++) {
            MoveToEx (hDC, j * 17, 0, NULL);
            LineTo (hDC, j * 17, uHeight);
        }    BITMAPFILEHEADER bmfh;
        bmfh.bfType = *(PWORD) "BM";
        bmfh.bfReserved1 = 0;
        bmfh.bfReserved2 = 0;
        bmfh.bfOffBits = sizeof (BITMAPFILEHEADER) + sizeof (BITMAPINFOHEADER) + sizeof (RGBQUAD) * 2;
        bmfh.bfSize = bmfh.bfOffBits + pbmi->bmiHeader.biSizeImage;    HANDLE hFile = CreateFile ("goal.bmp", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
        if (hFile != INVALID_HANDLE_VALUE) {
            DWORD dwWritten;
            WriteFile (hFile, &bmfh, sizeof (BITMAPFILEHEADER), &dwWritten, NULL);
            WriteFile (hFile, pbmi, sizeof (BITMAPINFOHEADER) + sizeof (RGBQUAD) * 2, &dwWritten, NULL);
            WriteFile (hFile, pvBits, pbmi->bmiHeader.biSizeImage, &dwWritten, NULL);        CloseHandle (hFile);
        }    DeleteObject (hFont);
        DeleteObject (hBitmap);
        DeleteDC (hDC);
        LocalFree (pbmi);    return 0;
    }
      

  3.   

    谢谢2楼,C看不懂,还是要谢谢,我所了解的情况是hzk16中取出的点阵都是横向取模方式得出的字节,但是有很多lcd要求为纵向取模,字节倒立,那如何将取出的字节转换为纵向取模,字节倒序呢(字节倒序容易)。
      

  4.   

    应该不是 C 语言看不懂的问题,我翻译个一模一样的 VB 程序给你看,估计你一样看不懂Private Const WHITENESS = &HFF0062       ' (DWORD) dest = WHITE
    Private Const GENERIC_WRITE = &H40000000
    Private Const CREATE_ALWAYS = 2
    Private Const INVALID_HANDLE_VALUE = -1Private Type BITMAPINFOHEADER '40 bytes
            biSize As Long
            biWidth As Long
            biHeight As Long
            biPlanes As Integer
            biBitCount As Integer
            biCompression As Long
            biSizeImage As Long
            biXPelsPerMeter As Long
            biYPelsPerMeter As Long
            biClrUsed As Long
            biClrImportant As Long
    End Type
    Private Type RGBQUAD
            rgbBlue As Byte
            rgbGreen As Byte
            rgbRed As Byte
            rgbReserved As Byte
    End Type
    Private Type BITMAPINFO
            bmiHeader As BITMAPINFOHEADER
            bmiColors As RGBQUAD
    End Type
    Private Type BITMAPFILEHEADER
            bfType As Integer
            bfSize As Long
            bfReserved1 As Integer
            bfReserved2 As Integer
            bfOffBits As Long
    End TypePrivate Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
    Private Declare Function CreateDIBSection Lib "gdi32" (ByVal hdc As Long, pBitmapInfo As BITMAPINFO, _
                                                            ByVal un As Long, ByVal lplpVoid As Long, _
                                                            ByVal handle As Long, ByVal dw As Long) As Long
    Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Private Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal H As Long, ByVal W As Long, _
                                                            ByVal E As Long, ByVal O As Long, ByVal W As Long, _
                                                            ByVal i As Long, ByVal u As Long, ByVal S As Long, _
                                                            ByVal c As Long, ByVal OP As Long, ByVal CP As Long, _
                                                            ByVal Q As Long, ByVal PAF As Long, ByVal F As String) As Long
    Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, _
                                                            ByVal nWidth As Long, ByVal nHeight As Long, _
                                                            ByVal hSrcDC As Long, ByVal xSrc As Long, _
                                                            ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, _
                                                            ByVal y As Long, ByVal lpString As String, _
                                                            ByVal nCount As Long) As Long
    Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpPoint As Long) As Long
    Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
    Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, _
                                                            ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, _
                                                            ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, _
                                                            ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
    Private Declare Function WriteFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, _
                                                            lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Long) As Long
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
    Sub Main()
        Dim uWidth As Long, uHeight As Long: uWidth = 18 + 17 * 256: uHeight = 18 + 17 * 128
        Dim pbmi As BITMAPINFO
        pbmi.bmiHeader.biSize = LenB(pbmi)
        pbmi.bmiHeader.biWidth = uWidth
        pbmi.bmiHeader.biHeight = uHeight
        pbmi.bmiHeader.biPlanes = 1
        pbmi.bmiHeader.biBitCount = 1
        pbmi.bmiHeader.biSizeImage = ((uWidth + 31) And &HFFFFFFE0) / 8 * uHeight
        pbmi.bmiColors [0].rgbBlue = 0
        pbmi.bmiColors [0].rgbGreen = 0
        pbmi.bmiColors [0].rgbRed = 0
        pbmi.bmiColors [1].rgbBlue = 255
        pbmi.bmiColors [1].rgbGreen = 255
        pbmi.bmiColors [1].rgbRed = 255
        
        Dim hdc As Long: hdc = CreateCompatibleDC(0)
        Dim pvBits As Long
        Dim hBitmap As Long: hBitmap = CreateDIBSection(hdc, pbmi, 0, pvBits, 0, 0)
        SelectObject hdc, hBitmap
        Dim hFont As Long: hFont = CreateFont(16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "宋体")
        SelectObject hdc, hFont
        BitBlt hdc, 0, 0, uWidth, uHeight, 0, 0, 0, WHITENESS
        
        Dim c As String
        Dim i As Integer, j As Integer
        For i = 128 To 256
            c = Right("00" & Hex(i), 2)
            TextOut hdc, 1, (i - 127) * 17 + 1, c, 2
        Next i
        For j = 0 To 256
            c = Right("00" & Hex(j), 2)
            TextOut hdc, (j + 1) * 17 + 1, 1, c, 2
        Next j
        For i = 128 To 256
            For j = 0 To 256
                c = Chr(Int("&H" & Hex(i) & Hex(j)))
                TextOut hdc, (j + 1) * 17 + 1, (i - 127) * 17 + 1, c, 2
            Next j
        Next i
        For i = 0 To 130
            MoveToEx hdc, 0, i * 17, 0
            LineTo hdc, uWidth, i * 17
        Next i
        For j = 0 To 258
            MoveToEx hdc, j * 17, 0, 0
            LineTo hdc, j * 17, uHeight
        Next j
        
        Dim bmfh As BITMAPFILEHEADER
        bmfh.bfType = CInt((Asc("B") * (2 ^ 8)) And Asc("M"))
        bmfh.bfReserved1 = 0
        bmfh.bfReserved2 = 0
        bmfh.bfOffBits = LenB(bmfh) + LenB(pbmi.bmiHeader) + LenB(pbmi.bmiColors) * 2
        bmfh.bfSize = bmfh.bfOffBits + pbmi.bmiHeader.biSizeImage    Dim hFile As Long: hFile = CreateFile("goal.bmp", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0)
        If hFile <> INVALID_HANDLE_VALUE Then
            Dim dwWritten As Long
            WriteFile hFile, bmfh, LenB(bmfh), dwWritten, 0
            WriteFile hFile, pbmi, sizeof(pbmi.bmiHeader) + sizeof(pbmi.bmiColors) * 2, dwWritten, 0
            WriteFile hFile, pvBits, pbmi.bmiHeader.biSizeImage, dwWritten, 0
            CloseHandle hFile
        End If
        
        DeleteObject hFont
        DeleteObject hBitmap
        DeleteDC hdc
    End Sub