norains的专栏

只专注于WINCE开发

用户操作
[即时聊天] [发私信] [加为好友]
norainsID:norains
142881次访问,排名598,好友0人,关注者53人。
代码其实是一种乐趣
norains的文章
原创 189 篇
翻译 0 篇
转载 10 篇
评论 274 篇
norains的公告
联系方式请看置顶文章
最近评论
dfdf:讨厌MFC!我觉得MFC就是太乱了!看似无用的代码不要不行,MD微软啥都给我们做完了,原理性的东西我们却永远没法搞懂了!
ironox:有个地方 我觉得很别扭,不知道怎么办好

比如说 CReg reg(HKEY_CURRENT_USER,TEXT("ControlPanel\Volume"));
ControlPanel\Volume 有可能不存在呀,这个该怎么处理哦?对象虽然创建了,出错了也没提示
szterry:呵呵,果然工作狂技术狂,同感,一样的感觉……不过我才刚毕业一年……搞IT就是玩……
jinlking:这个botton的实现只是在主窗口画了一块区域,对于事件的处理还要放在主窗口的窗口处理函数之中,在对应的消息处理上调用CheckTap来判断是否是此“按钮”,问一下,这种方法与把按钮封装在子窗口中有什么区别,二者使用那个更好?
KUODY:博主真是好人
文章分类
收藏
    相册
    动漫
    文章图片
    程序交流
    xumercury的BLOG
    狗友们的博客
    清蒸石斑鱼
    美女如刀锋
    茁茁的BLOG
    魅力老姐的窝
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    转载 EVC实现WIN CE下截屏收藏

    新一篇: EVC内存和文件交互 | 旧一篇: 查找WINCE外部存储器

    //======================================================================
    转自:
        http://www.write100.com/blog/user/erran/archives/2006/4000.html
    该作者联系方式:
        Emailerranlz@163.com
        MSN
    erranlz@hotmail.com
    注:
        只转了代码,原贴心得未转
    //======================================================================

    void OnScreenSave(const char *filename)
    {
     HDC  hScrDC, hMemDC;        
        int  width, height;
     
     //the pointer will save all pixel point's color value
     BYTE  *lpBitmapBits = NULL;
           
     //creates a device context for the screen device
        hScrDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);

     //get the screen point size
        width = GetDeviceCaps(hScrDC, HORZRES);
        height = GetDeviceCaps(hScrDC, VERTRES);

        //creates a memory device context (DC) compatible with the screen device(hScrDC) 
        hMemDC = CreateCompatibleDC(hScrDC);

     //initialise the struct BITMAPINFO for the bimap infomation,
     //in order to use the function CreateDIBSection
     //on wince os, each pixel stored by 24 bits(biBitCount=24)
     //and no compressing(biCompression=0)
        BITMAPINFO RGB24BitsBITMAPINFO;
        ZeroMemory(&RGB24BitsBITMAPINFO, sizeof(BITMAPINFO));
        RGB24BitsBITMAPINFO.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
        RGB24BitsBITMAPINFO.bmiHeader.biWidth = width;
        RGB24BitsBITMAPINFO.bmiHeader.biHeight = height;
        RGB24BitsBITMAPINFO.bmiHeader.biPlanes = 1;
        RGB24BitsBITMAPINFO.bmiHeader.biBitCount = 24;
      
     //use the function CreateDIBSection and SelectObject
     //in order to get the bimap pointer : lpBitmapBits
        HBITMAP directBmp = CreateDIBSection(hMemDC, (BITMAPINFO*)&RGB24BitsBITMAPINFO,
        DIB_RGB_COLORS, (void **)&lpBitmapBits, NULL, 0);
     HGDIOBJ previousObject = SelectObject(hMemDC, directBmp);

     // copy the screen dc to the memory dc
     BitBlt(hMemDC, 0, 0, width, height, hScrDC, 0, 0, SRCCOPY);
     
     //if you only want to get the every pixel color value,
     //you can begin here and the following part of this function will be unuseful;
     //the following part is in order to write file;

     //bimap file header in order to write bmp file
     BITMAPFILEHEADER bmBITMAPFILEHEADER;
     ZeroMemory(&bmBITMAPFILEHEADER, sizeof(BITMAPFILEHEADER));
     bmBITMAPFILEHEADER.bfType = 0x4d42;  //bmp 
        bmBITMAPFILEHEADER.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
        bmBITMAPFILEHEADER.bfSize = bmBITMAPFILEHEADER.bfOffBits + ((width*height)*3); ///3=(24 / 8)
     
     //write into file
     FILE *mStream = NULL;
     if((mStream = fopen(filename, "wb")))
     { 
      //write bitmap file header
      fwrite(&bmBITMAPFILEHEADER, sizeof(BITMAPFILEHEADER), 1, mStream);
      //write bitmap info
      fwrite(&(RGB24BitsBITMAPINFO.bmiHeader), sizeof(BITMAPINFOHEADER), 1, mStream);
      //write bitmap pixels data
      fwrite(lpBitmapBits, 3*width*height, 1, mStream);
      //close file
      fclose(mStream);
     }
     
     //delete
     DeleteObject(hMemDC);
     DeleteObject(hScrDC);
     DeleteObject(directBmp);
     DeleteObject(previousObject);

    }

    //测试代码:


    int WINAPI WinMain( HINSTANCE hInstance,
         HINSTANCE hPrevInstance,
         LPTSTR    lpCmdLine,
         int       nCmdShow)
    {
      // TODO: Place code here. 
     const char  filename[] = "screen.bmp";
     OnScreenSave(filename);
     return 0;
    }

    发表于 @ 2006年04月29日 15:50:00|评论(loading...)|编辑

    新一篇: EVC内存和文件交互 | 旧一篇: 查找WINCE外部存储器

    评论:没有评论。

    发表评论  


    登录
    Csdn Blog version 3.1a
    Copyright © norains