Jump to content

.JPG to .BMP convert missing


Recommended Posts

My situation;

- Import '.JPG'

- DrawText 'filename' to '.JPG'

- Convert to '.BMP' and Save It.

- Use it as WallPaper.

But, this code just showing 'DrawText', NOT shown at '.BMP'

What am I missing in this code;

$sv_SaveFrom = "C:\TEMP\WallPaper.jpg"
$sv_SaveTo = "C:\TEMP\WallPaper.bmp"

_GDIPlus_Startup()

$hImage = _GDIPlus_ImageLoadFromFile( $sv_SaveFrom )

$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP( $hImage )

$hDDC = _WinApi_GetDC( $hBitmap )

_WinApi_SelectObject( $hDDC , $hImage )

_DrawText( $hDDC , 0 , 50 , ( @DesktopWidth - 1 ) , 50 , $sv_SaveFrom , 0x00FFFF , 32 )
    ;_DrawText( $iv_HDc , $iv_PosX , $iv_PosY , $iv_Width , $iv_Height , $iv_TextIn [, $iv_ColorIn = 0x000AF0E8 [, $iv_SizeIn = 24 ]] )

$sCLSID = _GDIPlus_EncodersGetCLSID( "BMP" )

_GDIPlus_ImageSaveToFileEx( $hImage , $sv_SaveTo , $sCLSID )

_WinApi_DeleteObject( $hImage )

_WinApi_ReleaseDC( $hBitmap , $hDDC )

_GDIPlus_ImageDispose( $hBitmap )

_GDIPlus_ImageDispose( $hImage )

_GDIPlus_ShutDown()
Link to comment
Share on other sites

Hi, I think you will have an easier time if you didn't mix GDI+ with GDI. Try it like this instead:

#include <gdiplus.au3>

$sv_SaveFrom = "C:\TEMP\WallPaper.jpg"
$sv_SaveTo = "C:\TEMP\WallPaper.bmp"

_GDIPlus_Startup()

$hImage = _GDIPlus_ImageLoadFromFile( $sv_SaveFrom )
$hGraphics=_GDIPlus_ImageGetGraphicsContext($hImage)

$hFontFamily=_GDIPlus_FontFamilyCreate("Arial")
$hFont=_GDIPlus_FontCreate($hFontFamily,32)
$hStringFormat=_GDIPlus_StringFormatCreate()
$hRectF=_GDIPlus_RectFCreate(0,50,_GDIPlus_ImageGetWidth($hImage),50)
$hBrush=_GDIPlus_BrushCreateSolid(0xFF00FFFF)
_GDIPlus_GraphicsDrawStringEx($hGraphics,$sv_SaveFrom,$hFont,$hRectF,$hStringFormat,$hBrush)

_GDIPlus_BrushDispose($hBrush)
_GDIPlus_StringFormatDispose($hStringFormat)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFontFamily)
_GDIPlus_GraphicsDispose($hGraphics)

_GDIPlus_ImageSaveToFile($hImage,$sv_SaveTo)

_GDIPlus_ImageDispose($hImage)



_GDIPlus_ShutDown()

:)

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Hi, I think you will have an easier time if you didn't mix GDI+ with GDI. Try it like this instead:

#include <gdiplus.au3>

$sv_SaveFrom = "C:\TEMP\WallPaper.jpg"
$sv_SaveTo = "C:\TEMP\WallPaper.bmp"

_GDIPlus_Startup()

$hImage = _GDIPlus_ImageLoadFromFile( $sv_SaveFrom )
$hGraphics=_GDIPlus_ImageGetGraphicsContext($hImage)

$hFontFamily=_GDIPlus_FontFamilyCreate("Arial")
$hFont=_GDIPlus_FontCreate($hFontFamily,32)
$hStringFormat=_GDIPlus_StringFormatCreate()
$hRectF=_GDIPlus_RectFCreate(0,50,_GDIPlus_ImageGetWidth($hImage),50)
$hBrush=_GDIPlus_BrushCreateSolid(0xFF00FFFF)
_GDIPlus_GraphicsDrawStringEx($hGraphics,$sv_SaveFrom,$hFont,$hRectF,$hStringFormat,$hBrush)

_GDIPlus_BrushDispose($hBrush)
_GDIPlus_StringFormatDispose($hStringFormat)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFontFamily)
_GDIPlus_GraphicsDispose($hGraphics)

_GDIPlus_ImageSaveToFile($hImage,$sv_SaveTo)

_GDIPlus_ImageDispose($hImage)



_GDIPlus_ShutDown()

:)

Thx to advice.

But, any font character show.

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...