Sign in to follow this  
Followers 0
ChangMinYang

.JPG to .BMP convert missing

5 posts in this topic

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()

Share this post


Link to post
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!

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Thx to advice.

But, any font character show.

Sorry, what was that?


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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Sorry, what was that?

Thanks to your advice.

But, text character not appears on image.

Also, text character was not display on screen.

Edit: Solved.

Problem caused by 'DC'.

Now, I'm going to MASKING font display.

Edited by DllParse

Share this post


Link to post
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
Sign in to follow this  
Followers 0