Jump to content

gdi+ question


torels
 Share

Recommended Posts

how do I do this in gdi+ ?

Picture:

__________________

|..................................

|..pic1..........................

|..................................

|.............|-------------

|.............|

|-----------

| pic2

|__________________

I did it in ascii art but it has to come out as an image

so there is a pic1 on the top part

and a pic2 on the bottom part

and they are divided with a _|"" shaped line which goes across the whole picture

it's like a comic book's page :)

Edited by torels

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

Yes this is possible, if you look at my avatar and my slim banner its dynamicly created by a webserver (refresh and the clock and smily changes) running with some GDI+ commands.

Edited by jokke
UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.
Link to comment
Share on other sites

I know you can... but how to do it ?

how can I adapt an image to a shape...

and just display the parts included in the shape I want ?

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

Look inn the examples where you paste another image over another, you can change the Polygon to you'r needs.

Edited by jokke
UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.
Link to comment
Share on other sites

ok thanks

what command is it ?

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

_GDIPlus_GraphicsDrawPolygon()

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.
Link to comment
Share on other sites

and how do I cut the image as the poligon's shape?

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

you use the image handle inside the plygon.

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.
Link to comment
Share on other sites

I don't understand it

can you please post a little example ?

thanks!

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

I'll post something later, on may way out the door atm.

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.
Link to comment
Share on other sites

how do I do this in gdi+ ?

Picture:

__________________

|..................................

|..pic1..........................

|..................................

|.............|-------------

|.............|

|-----------

| pic2

|__________________

I did it in ascii art but it has to come out as an image

so there is a pic1 on the top part

and a pic2 on the bottom part

and they are divided with a _|"" shaped line which goes across the whole picture

it's like a comic book's page :)

from http://www.autoitscript.com/forum/index.ph...st&p=571390 , I used GdipCreateTexture() to fill a polygon.

For this example you must use a beta version of AutoIt. _GDIPlus_GraphicsFillPolygon() is not in the current release of AutoIt. Can be found on the forums though.

#include <GDIPlus.au3>
#include <Misc.au3>

_GDIPlus_Startup()

;$LOADBottomImage = FileOpenDialog("IMAGE", @DesktopDir, "Images (*.jpg;*.png;*.bmp;*.gif;*.tif)", 1)
;$LOADUpperImage = FileOpenDialog("IMAGE", @DesktopDir, "Images (*.jpg;*.png;*.bmp;*.gif;*.tif)", 1)
$LOADBottomImage = @SystemDir & "\oobe\images\mslogo.jpg"
$LOADUpperImage = @SystemDir & "\oobe\images\merlin.gif"

If @error Then Exit
$IMAGE = _GDIPlus_ImageLoadFromFile($LOADBottomImage)
$IMAGE2 = _GDIPlus_ImageLoadFromFile($LOADUpperImage)
$hBitmap = _GDIPlus_BitmapCreateFromFile($LOADUpperImage)

$X = _GDIPlus_ImageGetWidth($IMAGE)
$Y = _GDIPlus_ImageGetHeight($IMAGE)
$YU = _GDIPlus_ImageGetHeight($IMAGE2)
Local $iGuiX = $X, $iGuiY = $Y + $YU - 25

$GUI = GUICreate("GDI+", $iGuiX, $iGuiY, -1, -1, 0x80000000)

GUISetState(@SW_SHOW, $GUI)
$hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($GUI)
$hBMPBuff = _GDIPlus_BitmapCreateFromGraphics($iGuiX, $iGuiY, $hGraphicGUI)
$GRAPHIC = _GDIPlus_ImageGetGraphicsContext($hBMPBuff)

; Draw upper image
_GDIPlus_GraphicsDrawImage($GRAPHIC, $hBitmap, 0, 0)

;Use brush with image to fill polygon
; Points for polygon
;Local $aPoints[7][2] = [[6, 0],[40, 75],[240, 75],[240, 240],[0, 240],[0, 100],[40, 100]]
Local $aPoints[7][2] = [[6, 0],[$iGuiX / 6, $YU - 25],[$iGuiX, $YU - 25],[$iGuiX, $iGuiY],[0, $iGuiY], _
        [0, $YU],[$iGuiX / 6, $YU]]
$BRUSH = GdipCreateTexture($IMAGE, 0x00)
GDIPlus_GraphicsFillPolygon($GRAPHIC, $aPoints, $BRUSH)

; Draw line
Local $iPenSize = 4
$hPen = _GDIPlus_PenCreate(0xFFFFFFFF, $iPenSize, 2)
_GDIPlus_GraphicsDrawLine($GRAPHIC, 0, $YU, $iGuiX / 6 + $iPenSize / 2, $YU, $hPen)
_GDIPlus_GraphicsDrawLine($GRAPHIC, $iGuiX / 6, $YU + $iPenSize / 2, $iGuiX / 6, $YU - 25 - $iPenSize / 2, $hPen)
_GDIPlus_GraphicsDrawLine($GRAPHIC, $iGuiX / 6, $YU - 25, $iGuiX, $YU - 25, $hPen)

GUIRegisterMsg(0xF, "MY_PAINT"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3)
_WinAPI_RedrawWindow($GUI, 0, 0, 2) ;PAINT the window Flag $RDW_INTERNALPAINT = 0x0002

;_GDIPlus_ImageSaveToFile ($hBMPBuff, @DesktopCommonDir & "\GDIPlus_Image.jpg")

While 1
    $MSG = GUIGetMsg()
    If $MSG = -3 Then
        _WinAPI_DeleteObject($hBMPBuff)
        _WinAPI_DeleteObject($hBitmap)
        _GDIPlus_BrushDispose($BRUSH)
        _GDIPlus_PenDispose ($hPen)
        _GDIPlus_ImageDispose($IMAGE)
        _GDIPlus_ImageDispose($IMAGE2)
        _GDIPlus_GraphicsDispose($hGraphicGUI)
        _GDIPlus_GraphicsDispose($GRAPHIC)
        _GDIPlus_Shutdown()
        Exit
    EndIf
WEnd

Func GdipCreateTexture($hImg, $WrapMode = 0x00)
    Local $DLL = "gdiplus.dll"
    Local $RESULT
    $RESULT = DllCall($DLL, "int", "GdipCreateTexture", "int", $hImg, "int", $WrapMode, "int*", 0)
    Return $RESULT[3]
EndFunc   ;==>GdipCreateTexture

;Func to redraw the BMP on PAINT MSG
Func MY_PAINT($hWnd, $MSG, $wParam, $lParam)
    ; Check, if the GUI with the Graphic should be repainted
    If $hWnd = $GUI Then
        _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0)       
    EndIf   
EndFunc   ;==>MY_PAINT

Func GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush = 0)
    Local $iI, $iCount, $pPoints, $tPoints, $aResult, $tmpError, $tmpExError

    $iCount = $aPoints[0][0]
    $tPoints = DllStructCreate("int[" & $iCount * 2 & "]")
    $pPoints = DllStructGetPtr($tPoints)
    For $iI = 1 To $iCount
        DllStructSetData($tPoints, 1, $aPoints[$iI][0], (($iI - 1) * 2) + 1)
        DllStructSetData($tPoints, 1, $aPoints[$iI][1], (($iI - 1) * 2) + 2)
    Next

    _GDIPlus_BrushDefCreate($hBrush)
    $aResult = DllCall($ghGDIPDll, "int", "GdipFillPolygonI", "hWnd", $hGraphics, "hWnd", $hBrush, _
            "ptr", $pPoints, "int", $iCount, "int", "FillModeAlternate")
    $tmpError = @error
    $tmpExError = @extended
    _GDIPlus_BrushDefDispose()
    If $tmpError Then Return SetError($tmpError, $tmpExError, False)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc   ;==>GDIPlus_GraphicsFillPolygon

Edit: Added _GDIPlus_PenDispose ($hPen)

Added: Func GDIPlus_GraphicsFillPolygon(). Found at http://www.autoitscript.com/forum/index.ph...st&p=565937

Leading underscore removed to avoid conflict with beta version of _GDIPlus_GraphicsFillPolygon().

Script will now work on current version 3.2.12.1 AutoIt as well as beta version 3.2.13.7

Edited by Malkey
Link to comment
Share on other sites

Thanks

where do you get GdipCreateTexture() ??

and do you know other ways of doing it... maybe using the current version of autoit ?

Edited by torels

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...