lsf1012 发表于 2013-12-26 13:33:32

GDI 如何创建一幅jpg图片,并使用graphics进行操作后保存?

本帖最后由 lsf1012 于 2013-12-26 13:44 编辑

如题,整了好久,搞不成。。。
下面用的ScreenCapture是可以的。但BitmapCreateFromFile是不行的。#include <GDIPlus.au3>
#include <ScreenCapture.au3>

Example()

Func Example()
    Local $hBitmap,$hImage

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    $hBitmap = _ScreenCapture_Capture("")
    ;$hBitmap=_GDIPlus_BitmapCreateFromFile(@MyDocumentsDir & "\XX.JPG")
    $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
    _GDIPlus_GraphicsClear($hGraphic,0xFFFF0FFF)
    ; Save bitmap to file
    _GDIPlus_ImageSaveToFile($hImage, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Clean up resources
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_DeleteObject($hBitmap)

    ; Shut down GDI+ library
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Ycxw2008 发表于 2013-12-27 04:48:21

什么意思?是这个意思吗#include <WinAPIEx.au3>
#include <APIConstants.au3>
#include <GDIPLus.au3>
#include <ScreenCapture.au3>

_ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image.jpg", 0, 0, 600, 400)
_GDIPlus_Startup()
Local $Image=_GDIPlus_BitmapCreateFromFile(@MyDocumentsDir & "\GDIPlus_Image.jpg")
Local $hImage=_GDIPlus_BitmapCreateFromScan0(400, 300,0, $GDIP_PXF32ARGB)
Local $hGraphics=_GDIPlus_ImageGetGraphicsContext($hImage)
_GDIPlus_GraphicsDrawImageRectRect($hGraphics,$Image,100,50,400,300,0,0,400,300)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_ImageSaveToFile($hImage,@MyDocumentsDir & "\GDIPlus_Image2.jpg")
_GDIPlus_BitmapDispose($hImage)
_GDIPlus_BitmapDispose($Image)
_GDIPlus_Shutdown()
页: [1]
查看完整版本: GDI 如何创建一幅jpg图片,并使用graphics进行操作后保存?