zoukankan      html  css  js  c++  java
  • DrawImage调查

    Status DrawImage(

      [in]  Image *image,

      [in]  const Point *destPoints,

      [in]  INT count,

      [in]  INT srcx,

      [in]  INT srcy,

      [in]  INT srcwidth,

      [in]  INT srcheight,

      [in]  Unit srcUnit,

      [in]  ImageAttributes *imageAttributes,

      [in]  DrawImageAbort callback,

      [in]  VOID *callbackData

    );

    imageAttributes [in]

    ImageAttributes

    Pointer to an ImageAttributes object that specifies the color and size attributes of the image to be drawn. The default value is NULL.

    callback [in]

    DrawImageAbort

    Callback method used to cancel the drawing in progress. The default value is NULL. This method is called frequently to check whether to stop execution of the DrawImage method according to application-determined criteria.

    callbackData [in]

    VOID

    Pointer to additional data used by the method specified by the callback parameter. The default value is NULL.

    Remarks

    The portion of the source image to be drawn is scaled to fit the parallelogram.

    Demo模式

    声明

    BOOL CALLBACK DrawImageCallback(VOID* callbackdata);

    定义

    BOOL CALLBACK DrawImageCallback(VOID* callbackdata)

    {

         // Test for call that passes callBackData parameter.

         if(reinterpret_cast<LPCTSTR>(callbackdata) == L"Not Draw")

         {

             // If no callBackData passed, abort DrawImage method.

             return TRUE;

         }

         else

         {

             // If callBackData passed, continue DrawImage method.

             return FALSE;

         }

    }

    调用

    DrawImageAbort DrawImageCallbackPtr = DrawImageCallback;

    graphics.DrawImage(

        &image,

        destRect,

        srcX,

        srcY,

        srcWidth,

        srcHeight,

        UnitPixel,

        &remapAttributes,

        DrawImageCallbackPtr,

        L"Not Draw");

    //  L"Draw");

    类型定义

    GdiPlusTypes.h

    extern "C" {

    typedef BOOL (CALLBACK * ImageAbort)(VOID *);

    typedef ImageAbort DrawImageAbort;

    typedef ImageAbort GetThumbnailImageAbort;

    }

    WinDef.h

    #define CALLBACK    __stdcall

    Test模式

    BOOL CALLBACK DrawImageCallback(VOID* callbackdata)

    {

        int* ptrCount = reinterpret_cast<int*>(callbackdata);

        if (10 == *ptrCount)

        {

            return TRUE;

        }

        else

        {

            ++(*ptrCount);

            return FALSE;

        }

    }

    调用

    int iCount = 0;

    DrawImageAbort DrawImageCallbackPtr = DrawImageCallback;

    graphics.DrawImage(

        &image,

        destRect,

        srcX,

        srcY,

        srcWidth,

        srcHeight,

        UnitPixel,

        &remapAttributes,

        DrawImageCallbackPtr,

        &iCount);

    Remark

    如之前的参数描述,在DrawImage过程中,DrawImageAbort会多次被调用,以时刻检查绘图过程中是否符合停止绘图的条件,一旦条件满足则停止绘图,本次绘图不产生任何图像,此时函数返回Aborted。

    一个未知问题:调试DrawImage时,在DrawImageCallback里设断点,当快速连按F5时,该函数只走了几次,而慢慢点的时候则会走很多次。

  • 相关阅读:
    进程池,线程池,协程,gevent模块,协程实现单线程服务端与多线程客户端通信,IO模型
    线程相关 GIL queue event 死锁与递归锁 信号量l
    生产者消费者模型 线程相关
    进程的开启方式 进程的join方法 进程间的内存隔离 其他相关方法 守护进程 互斥锁
    udp协议 及相关 利用tcp上传文件 socketserver服务
    socket套接字 tcp协议下的粘包处理
    常用模块的完善 random shutil shevle 三流 logging
    day 29 元类
    Django入门
    MySQL多表查询
  • 原文地址:https://www.cnblogs.com/BeyondTechnology/p/1925955.html
Copyright © 2011-2022 走看看