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时,该函数只走了几次,而慢慢点的时候则会走很多次。

  • 相关阅读:
    回调函数和表驱动法编程
    学会看datasheet W25Q128为例
    STM32 Makefile的一次bug解决过程
    STM32 一种参数检查用法介绍
    STM32 中断和事件
    STM32 OV2640将数据缓存至SRAM
    STM32 .ld链接文件分析及一次bug解决过程
    浅谈嵌入式软件设计
    STM32 Makefile的设置和工程管理
    [转]Linux下的lds链接脚本详解
  • 原文地址:https://www.cnblogs.com/BeyondTechnology/p/1925955.html
Copyright © 2011-2022 走看看