zoukankan      html  css  js  c++  java
  • 不同的色深条件(8、16、24、32),像素绘制方式

    lpddsprimary->Lock(NULL,&ddsd,
                  DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,NULL);

    // get video pointer to primary surface
    // cast to VOID * since we don't know what we are
    // dealing with yet
    UCHAR *primary_buffer = (UCHAR *)ddsd.lpSurface;      

    // what is the color depth?
    if (pixel_format == 32)
       {
        // draw 10 random pixels in 32 bit mode
        for (int index=0; index<10; index++)
            {
            int x=rand()%(client.right - client.left) + client.left;
            int y=rand()%(client.bottom - client.top) + client.top;
            DWORD color = _RGB32BIT(0,rand()%256, rand()%256, rand()%256);
            *((DWORD *)(primary_buffer + x*4 + y*ddsd.lPitch)) = color;
            } // end for index
        } // end if 24 bit

    else
    if (pixel_format == 24)
       {
        // draw 10 random pixels in 24 bit mode (very rare???)
        for (int index=0; index<10; index++)
            {
            int x=rand()%(client.right - client.left) + client.left;
            int y=rand()%(client.bottom - client.top) + client.top;
            ((primary_buffer + x*3 + y*ddsd.lPitch))[0] = rand()%256;
            ((primary_buffer + x*3 + y*ddsd.lPitch))[1] = rand()%256;
            ((primary_buffer + x*3 + y*ddsd.lPitch))[2] = rand()%256;
            } // end for index
        } // end if 24 bit
    else

    if (pixel_format == 16)
        {
        // draw 10 random pixels in 16 bit mode
        for (int index=0; index<10; index++)
            {
            int x=rand()%(client.right - client.left) + client.left;
            int y=rand()%(client.bottom - client.top) + client.top;
            USHORT color = _RGB16BIT565(rand()%256, rand()%256, rand()%256);
            *((USHORT *)(primary_buffer + x*2 + y*ddsd.lPitch)) = color;
            } // end for index
        } // end if 16 bit
    else
        {// assume 8 bits per pixel
        // draw 10 random pixels in 8 bit mode
        for (int index=0; index<10; index++)
            {
            int x=rand()%(client.right - client.left) + client.left;
            int y=rand()%(client.bottom - client.top) + client.top;
            UCHAR color = rand()%256;
            primary_buffer[x + y*ddsd.lPitch] = color;
            } // end for index
        } // end else

    // unlock primary buffer
    if (FAILED(lpddsprimary->Unlock(NULL)))
       return(0);

  • 相关阅读:
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.RequestContext
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils
    Caused by: java.lang.ClassNotFoundException: javassist.ClassPool
    Caused by: java.lang.ClassNotFoundException: ognl.PropertyAccessor
    利用DBLINK同步表数据库--老刘
    100万并发连接服务器笔记之1M并发连接目标达成
    模拟row cache lock
    redis读写性能测试
    Adobe RIA 开发工程师认证考试大纲
  • 原文地址:https://www.cnblogs.com/orangeblog/p/2816074.html
Copyright © 2011-2022 走看看