奇怪的gdi绘字问题。。图
本帖最后由 xzxnovice 于 2011-4-19 12:41 编辑#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GDIPlus.au3>
#include <String.au3>
Opt('MustDeclareVars', 1)
Global Const $width = 800
Global Const $height = 600
Global Const $pi_div_180 = 4 * ATan(1) / 180
Global $hwnd, $graphics, $backbuffer, $bitmap, $Pen, $arrTxt1, $arrTxt2, $fontsize_txt1, $fontsize_txt2,$brush1
Global $brush_color, $hFamily1, $hFamily2, $hFont1, $hFont2, $hFormat, $tLayout
Global $ScreenDc, $dc, $tSize, $pSize, $tSource, $pSource, $tBlend, $pBlend, $tPoint, $pPoint, $gdibitmap
$hwnd = GUICreate("gdi+绘字", $width, $height, -1, -1, 0, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
_GDIPlus_Startup()
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
;~ _GDIPlus_GraphicsSetSmoothingMode($backbuffer, 2)
$ScreenDc = _WinAPI_GetDC($hWnd)
$dc = _WinAPI_CreateCompatibleDC($ScreenDc)
; _WinAPI_UpdateLayeredWindow parameters
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $width)
DllStructSetData($tSize, "Y", $height)
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", 255)
DllStructSetData($tBlend, "Format", 1)
$tPoint = DllStructCreate($tagPOINT)
$pPoint = DllStructGetPtr($tPoint)
DllStructSetData($tPoint, "X", 0)
DllStructSetData($tPoint, "Y", 0)
GUISetState()
$brush1 = _GDIPlus_BrushCreateSolid(0x96ffffff)
;~ _GDIPlus_BrushSetSolidColor($brush1, 0x96ffffff)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily1 = _GDIPlus_FontFamilyCreate("黑体")
;~ $hFont1 = _GDIPlus_FontCreate($hFamily1,500, 1)
For $i=10 To 200 Step 20
$hFont1 = _GDIPlus_FontCreate($hFamily1,$i,0, 2)
$tLayout = _GDIPlus_RectFCreate(0, $i*2)
;~_GDIPlus_GraphicsClear($backbuffer, 0x00000000)
_GDIPlus_GraphicsDrawStringEx($backbuffer, $i, $hFont1, $tLayout, $hFormat,$brush1)
next
$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($bitmap)
_WinAPI_SelectObject($dc, $gdibitmap)
_WinAPI_UpdateLayeredWindow($hWnd, $ScreenDc, 0, $pSize, $dc, $pSource, 0, $pBlend, 2)
Do
Until GUIGetMsg()= -3
_WinAPI_DeleteDC($dc)
_WinAPI_ReleaseDC($hWnd, $ScreenDc)
_GDIPlus_FontDispose($hFont1)
_GDIPlus_FontDispose($hFont2)
_GDIPlus_FontFamilyDispose($hFamily1)
_GDIPlus_FontFamilyDispose($hFamily2)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_GraphicsDispose($backbuffer)
_GDIPlus_BitmapDispose($bitmap)
_GDIPlus_GraphicsDispose($graphics)
_GDIPlus_Shutdown()
GUIDelete($hwnd)
字体小时(大概100以下),文字下方有明显的黑色背景,字体大点的话没黑色背影
把字绘到图像中,也不怕,但绘到空画板时出现这种情况,我用的是windows 7
xp会吗?我没试过
Window 7 下这样了。。xp 正常
XP測試,沒有黑色背景。 XP測試,沒有黑色背景。
binshiwo 发表于 2011-4-19 09:05 http://www.autoitx.com/images/common/back.gif
刚才在xp试了一下,正常的. XP測試,沒有黑色背景。
binshiwo 发表于 2011-4-19 09:05 http://www.autoitx.com/images/common/back.gif
刚才在xp试了一下,正常的. xp试了,正常的.没发现有黑色背景 回复 5# guang19831217
是啊,xp下正常,windows 7 不正常,不会是系统问题吧?,有window7的帮忙看看 测试了,win7下确实会那样,原因不明 autoit版本过低所致。。。 回复 8# kn007
我用的是论坛的3.3.6.1 第二汉化版下载(2010-11-03).
你试过吗?什么版本正常 ? 搜了几天还没解决。。。自顶一下
页:
[1]