PIXNET Logo登入

阿勇的blog

跳到主文

歡迎光臨阿勇在痞客邦的小天地

部落格全站分類:不設分類

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 3月 12 週六 201113:14
  • load unicode file

#include <stdio.h>
#include <stdlib.h>
#include <locale.h> //function: setlocale
#include <ctype.h> //define WEOF
/*
*
*/
int main(int argc, char** argv) {
setlocale(LC_CTYPE, ""); //all printf is encode by unicode
FILE *fp;
fp = fopen("file.txt", "rb");//load UTF16-LE
fseek(fp, 0, SEEK_SET);
if (fp) {
wchar_t c = L' ';
while ((c = fgetwc(fp)) != WEOF)
{
printf("%lc\n", c);
}
fclose(fp);
}
return (EXIT_SUCCESS);
}
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(1)

  • 個人分類:c
▲top
  • 3月 09 週三 201114:21
  • 讓netbeans變成網頁編輯器


tools->plugins->available plugins->checking "Embedded Browser UI - XUL Runner" and "Web Preview"->installtools->options->Web Browser->Embedded Mozilla Browserclick preview
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(14)

  • 個人分類:NetBeans
▲top
  • 3月 01 週二 201114:41
  • DevCon 裝置管理員 (command版)

最近因為要測試usb dongle
需要一直插拔
這時候就非常需要devcon
devcon remove "USB\VID_0403&PID_6001"
devcon rescan
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(207)

  • 個人分類:windows
▲top
  • 2月 15 週二 201113:58
  • Mercurial quick start




來源
中文來源
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:hg
▲top
  • 1月 20 週四 201113:31
  • QGraphicsItem的碰撞偵測


先利用collidingItems求出所有item發生碰撞的QGraphicsItem,
在利用qgraphicsitem_cast來過濾QGraphicsItem類別

QGraphicsScene *scene = new QGraphicsScene;
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
scene->addRect(i*20,j*20,20,20);
}
}
QGraphicsPixmapItem *item = scene->addPixmap(QPixmap("r://img.png"));
QList<QGraphicsItem *> list = scene->collidingItems(item);
foreach(QGraphicsItem *l, list){
QGraphicsRectItem *led = qgraphicsitem_cast<QGraphicsRectItem *>(l);
if(led!=0){
led->setBrush(QBrush(Qt::yellow));
}
}
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(109)

  • 個人分類:Qt
▲top
  • 1月 09 週日 201121:53
  • 邊框字


上星期突然有個想法,為何不能印出邊框字呢
於是我稍微修改了一下之前的點陣字
作一個自動將點陣字轉邊框字
完整程式在下面
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(4)

  • 個人分類:bitmap font
▲top
  • 1月 01 週六 201119:35
  • bdf點陣字(二)

上一個方法,由於bdf檔是即時讀取,所以效能較差。
所以我利用bdf2c產生字型的font.h和font.c檔案
之後只要
#include "font.h"
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(8)

  • 個人分類:bitmap font
▲top
  • 1月 01 週六 201116:37
  • bdf點陣字


bdf font是文字格式的點陣字型
我是將unifont(unicode bdf font),掃成我定義的bitmap格式
1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1111111 1111 11111111111 1 1 1 11111 1
1 1 1 1 1111111 1 1 1 1 1 1
1 1 1 1 1 11 1 1 111 1 1 111
1 1 1 1 1 1 1 1 1 1 1 11111 1
11111111 111111 1111111111 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1111 1 1 1111
1 1 1 1 1 1 1 1111111111 1 11111 1
1111111 1 1 1 1 1 1 1
1 1 1 111111111111111 1 1 1 111111111111111
1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 11 1 11
1 1 1 1 1 1 1 1 11 1 11
1 1 1 1 1 1 11 1
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(27)

  • 個人分類:bitmap font
▲top
  • 12月 31 週五 201016:45
  • 利用Qt轉出bitmap點陣字

一般轉點陣字都是用win api
不過我來寫一個Qt的方式
觀念是一樣的
先將字畫出來,在擷取下來,轉成點陣圖
所以我的作法是
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(0) 人氣(84)

  • 個人分類:bitmap font
▲top
  • 12月 31 週五 201016:07
  • 利用freetype轉出bitmap點陣字

rasters是利用freetype將特定字型文字轉成bitmap字串。
bool rasters(const wchar_t texts[], Bitmap *bitmap)
{
    if(texts[0] == '\0') {
        return true;
    }
    FT_Library library;
    if (FT_Init_FreeType(&library)) {
        return false;
    }
    FT_Face face;
    if(FT_New_Face(library, "C:/WINDOWS/Fonts/MINGLIU.TTC", 0, &face)) {
        FT_Done_FreeType(library);
        return false;
    }
    int pixalWidth = 36;
    int pixalHeight = 36;
    if(FT_Set_Pixel_Sizes(face, pixalWidth, pixalHeight)) {
        FT_Done_Face(face);
        FT_Done_FreeType(library);
        return false;
    }
    FT_Select_Charmap(face, FT_ENCODING_UNICODE);
    for(int i=0; i<wcslen(texts); i++) {
        unsigned int ucode = texts[i];
        FT_UInt glyph_index = FT_Get_Char_Index(face, ucode);
        if(!glyph_index) {
            continue;
        }
        if (FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT)) {
            continue;
        }
        if (face->glyph->format != FT_GLYPH_FORMAT_BITMAP) {
            if (FT_Render_Glyph(face->glyph, FT_RENDER_MODE_MONO)) {
                continue;
            }
        }
        Bitmap font = {    face->glyph->bitmap_left,
                        face->glyph->bitmap_top - face->glyph->bitmap.rows,
                        face->glyph->bitmap.width,
                        face->glyph->bitmap.rows,
                        face->glyph->bitmap.pitch,
                        face->glyph->bitmap.buffer
                      };
        combinetext(bitmap, &font);
    }
    FT_Done_Face(face);
    FT_Done_FreeType(library);
    return true;
}
(繼續閱讀...)
文章標籤

阿勇 發表在 痞客邦 留言(1) 人氣(176)

  • 個人分類:bitmap font
▲top
«1...56713»

個人資訊

阿勇
暱稱:
阿勇
分類:
不設分類
好友:
累積中
地區:

熱門文章

  • (0)Cordova速記
  • (0)Cordova run simulation
  • (5)swift速記
  • (1)cordova發布到andriod
  • (4)迷香
  • (11)notification results in “unrecognized selector sent to instance…”
  • (0)分開設定xcode的configureration
  • (10)關於doesNotRecognizeSelector引起的exception crash
  • (1)在SQL中,當二個鍵同時相等時,唯一鍵成立。
  • (56)防止繼承的delegate跟原本的衝突(how to extend a protocol for a delegate in objective C)

文章分類

  • 替代役的日子 (5)
  • 黑色鈣片 (4)
  • java (3)
  • picasa (1)
  • lua (1)
  • mingw (1)
  • nsis (1)
  • squirrel (1)
  • freetype (1)
  • bitmap font (7)
  • windows (5)
  • c (1)
  • NetBeans (2)
  • uml (1)
  • html5 (1)
  • Wheel Light (4)
  • Qt (26)
  • opengl (6)
  • chrome (2)
  • hg (2)
  • mac (4)
  • apns (1)
  • python (4)
  • php (2)
  • SQL (4)
  • iOS (3)
  • xcode (4)
  • Objective-C (8)
  • phonegap (1)
  • swift (1)
  • cordova (2)
  • 未分類文章 (1)

最新文章

  • Cordova速記
  • Cordova run simulation
  • swift速記
  • cordova發布到andriod
  • 迷香
  • notification results in “unrecognized selector sent to instance…”
  • 分開設定xcode的configureration
  • 關於doesNotRecognizeSelector引起的exception crash
  • 在SQL中,當二個鍵同時相等時,唯一鍵成立。
  • 防止繼承的delegate跟原本的衝突(how to extend a protocol for a delegate in objective C)

動態訂閱

文章精選

文章搜尋

誰來我家

參觀人氣

  • 本日人氣:
  • 累積人氣: