Jump to content

_GDIPlus question


Recommended Posts

Hi there

I have 2 images in a gdiplus graphic and I want to save the whole graphic to a bmp image (or eventually jpg) but using

$Img = _GDIPlus_BitmapCreateFromGraphics(19,19,$hGraphics)
_GDIPlus_ImageSaveToFile($Img,"C:\img.bmp")

all I get is a Black 19x19 bitmap

How can I rsolve the problem ?

thanks in advance :)

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

nothing ?

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

Hi there

I have 2 images in a gdiplus graphic and I want to save the whole graphic to a bmp image (or eventually jpg) but using

$Img = _GDIPlus_BitmapCreateFromGraphics(19,19,$hGraphics)
_GDIPlus_ImageSaveToFile($Img,"C:\img.bmp")

all I get is a Black 19x19 bitmap

How can I rsolve the problem ?

thanks in advance :)

Do you have a larger code sample to work from (specifically, the source for the handle $hGraphics)?

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Link to comment
Share on other sites

;torels - emoticon.mixer
#include <GDIPlus.au3>
Dim $nt = 0, $nb = 0, $it, $ib
#Region ### START Koda GUI section ### Form=
$Gui = GUICreate("Emoticon Maker - torels_", 146, 134, 193, 125)
GUISetBkColor(0xFFFFFF)
$tf = GUICtrlCreateButton(">", 88, 16, 17, 17, 0)
$tb = GUICtrlCreateButton("<", 40, 16, 17, 17, 0)
$bf = GUICtrlCreateButton(">", 88, 32, 17, 17, 0)
$bb = GUICtrlCreateButton("<", 40, 32, 17, 17, 0)
$Label1 = GUICtrlCreateLabel("Copyright (C) 2008 torels_", 5, 96, 125, 17)
$Label2 = GUICtrlCreateLabel("<http://torels.altervista.org>", 5, 112, 135, 17)
$Save = GUICtrlCreateButton("SaVe EmOtIcOn!", 8, 64, 129, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

_GDIPlus_Startup()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND(HWnd($gui))
$t = _GDIPlus_GraphicsDrawImage($hGraphics,"C:\Documents and Settings\Gabriele ( admin )\Documenti\Immagini\emoticon-creator\0t.jpg",(146/2)-10,16)
$b = _GDIPlus_GraphicsDrawImage($hGraphics,"C:\Documents and Settings\Gabriele ( admin )\Documenti\Immagini\emoticon-creator\0b.jpg",(146/2)-10,26)
While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $tf
            $nt += 1
            If Not FileExists("C:\Documents and Settings\Gabriele ( admin )\Documenti\Immagini\emoticon-creator\" & $nt & "t.jpg") then $nt -= 1
            $it = _GDIPlus_ImageLoadFromFile("C:\Documents and Settings\Gabriele ( admin )\Documenti\Immagini\emoticon-creator\" & $nt & "t.jpg")
            _GDIPlus_ImageDispose($t)
            global $t = _GDIPlus_GraphicsDrawImage($hGraphics,$it,(146/2)-13,16)
        Case $tb
            $nt -= 1
            If Not FileExists("C:\Documents and Settings\Gabriele ( admin )\Documenti\Immagini\emoticon-creator\" & $nt & "t.jpg") then $nt += 1
            $it = _GDIPlus_ImageLoadFromFile("C:\Documents and Settings\Gabriele ( admin )\Documenti\Immagini\emoticon-creator\" & $nt & "t.jpg")
            _GDIPlus_ImageDispose($t)
            global $t = _GDIPlus_GraphicsDrawImage($hGraphics,$it,(146/2)-13,16)
        Case $bf
            $nb += 1
            If Not FileExists("C:\Documents and Settings\Gabriele ( admin )\Documenti\Immagini\emoticon-creator\" & $nb & "b.jpg") then $nb -= 1
            _GDIPlus_ImageDispose($b)
            $ib = _GDIPlus_ImageLoadFromFile("C:\Documents and Settings\Gabriele ( admin )\Documenti\Immagini\emoticon-creator\" & $nb & "b.jpg")
            $b = _GDIPlus_GraphicsDrawImage($hGraphics,$ib,(146/2)-13,29)
        Case $bb
            $nb -= 1
            If Not FileExists("C:\Documents and Settings\Gabriele ( admin )\Documenti\Immagini\emoticon-creator\" & $nb & "t.jpg") then $nb += 1
            _GDIPlus_ImageDispose($b)
            $ib = _GDIPlus_ImageLoadFromFile("C:\Documents and Settings\Gabriele ( admin )\Documenti\Immagini\emoticon-creator\" & $nb & "b.jpg")
            $b = _GDIPlus_GraphicsDrawImage($hGraphics,$ib,(146/2)-13,29)
        Case $Save
            $gImg = _GDIPlus_BitmapCreateFromGraphics(19,19,$hGraphics)
            _GDIPlus_ImageDispose($t)
            _GDIPlus_ImageDispose($b)
        ;$jpg = _GDIPlus_EncodersGetCLSID("JPG")
            _GDIPlus_ImageSaveToFile($gImg,"C:\img.bmp")
            
EndSwitch
WEnd

this is all the code :)

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

Try this:

Case $Save
            $hBitmap1 = _GDIPlus_BitmapCreateFromGraphics(19,19,$hGraphics)
            $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBitmap1)
            _GDIPlus_ImageSaveToFile($hImage1, "C:\img.bmp")
;~             _GDIPlus_ImageSaveToFile($hImage1, "C:\img.jpg") ; save as JPG

        ; Clean up resources
        _GDIPlus_ImageDispose ($hImage1)
        _WinAPI_DeleteObject ($hBitmap1)
Edited by Zedna
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...