找回密码
 加入
搜索
查看: 4217|回复: 9

[图形处理] 奇怪的gdi绘字问题。。图

  [复制链接]
发表于 2011-4-19 08:56:15 | 显示全部楼层 |阅读模式
本帖最后由 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 正常

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-4-19 09:05:33 | 显示全部楼层
XP測試,沒有黑色背景。
 楼主| 发表于 2011-4-19 09:14:30 | 显示全部楼层
XP測試,沒有黑色背景。
binshiwo 发表于 2011-4-19 09:05



    刚才在xp试了一下,正常的.
 楼主| 发表于 2011-4-19 09:14:33 | 显示全部楼层
XP測試,沒有黑色背景。
binshiwo 发表于 2011-4-19 09:05



       刚才在xp试了一下,正常的.
发表于 2011-4-19 12:36:02 | 显示全部楼层
xp试了,正常的.没发现有黑色背景
 楼主| 发表于 2011-4-19 12:42:44 | 显示全部楼层
回复 5# guang19831217


    是啊,xp下正常,windows 7 不正常,不会是系统问题吧?,有window7的帮忙看看
发表于 2011-4-19 14:27:56 | 显示全部楼层
测试了,win7下确实会那样,原因不明
发表于 2011-4-19 17:02:08 | 显示全部楼层
autoit版本过低所致。。。
 楼主| 发表于 2011-4-19 17:34:48 | 显示全部楼层
回复 8# kn007


    我用的是论坛的3.3.6.1 第二汉化版下载(2010-11-03)  .


你试过吗?什么版本正常 ?
 楼主| 发表于 2011-4-22 20:15:42 | 显示全部楼层
搜了几天还没解决。。。自顶一下
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-14 14:41 , Processed in 0.081072 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表