AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ConvertImage() Convert and resize images with 1 function
Goto page Previous  1, 2
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
DataLife



Joined: 27 Apr 2008
Posts: 369

PostPosted: Thu Jan 22, 2009 1:42 pm    Post subject: Reply with quote

Mylistbox is defined earlier in the script and will have a file name in the format of
pic.jpg

I want to convert it to bmp and retain the original file name with the extension bmp. As in pic.bmp

I tried this
Code:
ConvertImage(mylistbox,"mylistbox.bmp")
this gave my converted picture the name
mylistbox.bmp


Code:
ConvertImage(MyListbox,MyListbox . ".bmp")
this gave my converted picture the name
pic.jpg.bmp


Code:
ConvertImage(mylistbox . ".jpg",mylistbox . ".bmp")
this gave my converted picture the name
pic.jpg
_________________
Unless otherwise stated, all code is untested

Check out my scripts.
http://www.autohotkey.net/~DataLife/MyIpChanger/MyIpChanger.ahk
http://www.autohotkey.net/~DataLife/XPSnap.ahk
http://www.autohotkey.net/~DataLife/SavePictureAs.ahk
Back to top
View user's profile Send private message Send e-mail
DataLife



Joined: 27 Apr 2008
Posts: 369

PostPosted: Thu Jan 22, 2009 1:44 pm    Post subject: Reply with quote

I was certain I could remove the extension from mylistbox because I read somewhere that convertimage() did not care what the original extension was.

I was hoping to avoid that.

thanks
DataLife
_________________
Unless otherwise stated, all code is untested

Check out my scripts.
http://www.autohotkey.net/~DataLife/MyIpChanger/MyIpChanger.ahk
http://www.autohotkey.net/~DataLife/XPSnap.ahk
http://www.autohotkey.net/~DataLife/SavePictureAs.ahk
Back to top
View user's profile Send private message Send e-mail
tic



Joined: 22 Apr 2007
Posts: 1786

PostPosted: Thu Jan 22, 2009 2:26 pm    Post subject: Reply with quote

lol, everyones disregarded that this function is old and rubbish Wink

The gdi+ library will do this much better

Code:
#Include Gdip.ahk

pToken := Gdip_Startup()
pBitmap := Gdip_CreateBitmapFromFile("file.jpg")
Gdip_SaveBitmapToFile(pBitmap, "file.bmp")
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)


I know its longer, but that could all be wrapped into one function:

Code:
ConvertImage(sInput, sOutput)
{
   pBitmap := Gdip_CreateBitmapFromFile(sInput)
   Gdip_SaveBitmapToFile(pBitmap, sOutput)
   Gdip_DisposeImage(pBitmap)
}


Use that instead!
Back to top
View user's profile Send private message
oliver.lipkau



Joined: 17 Sep 2006
Posts: 85
Location: Munique/Germany

PostPosted: Thu Jan 22, 2009 2:28 pm    Post subject: Reply with quote

tic wrote:
lol, everyones disregarded that this function is old and rubbish Wink

The gdi+ library will do this much better

Code:
#Include Gdip.ahk

pToken := Gdip_Startup()
pBitmap := Gdip_CreateBitmapFromFile("file.jpg")
Gdip_SaveBitmapToFile(pBitmap, "file.bmp")
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)


I know its longer, but that could all be wrapped into one function:

Code:
ConvertImage(sInput, sOutput)
{
   pBitmap := Gdip_CreateBitmapFromFile(sInput)
   Gdip_SaveBitmapToFile(pBitmap, sOutput)
   Gdip_DisposeImage(pBitmap)
}


Use that instead!

tic,
can you past a image to the clipboard using your GDI lib?
Thanks
Back to top
View user's profile Send private message Send e-mail MSN Messenger
adamrgolf



Joined: 28 Dec 2006
Posts: 440

PostPosted: Tue Mar 02, 2010 10:28 pm    Post subject: Reply with quote

Is it possible to convert an input image from memory instead of from file?
Back to top
View user's profile Send private message
Lithodora



Joined: 02 Jul 2006
Posts: 23

PostPosted: Tue Apr 06, 2010 12:06 am    Post subject: Reply with quote

Is there a way to get a hold of this function because the link in the OP doesn't work?
Back to top
View user's profile Send private message
Wicked - Guest
Guest





PostPosted: Tue Apr 06, 2010 3:06 am    Post subject: Reply with quote

A good idea would be a similar function for bitmaps stored in memory. For example using your GDI+ library. Not a convert image, but a simple resize.

Maybe there is one already, but I've not had much time to look. Then you could do:

Code:
pBitmap := ConvertImage(pBitmap, 200, 100)


See what I mean? If there is one already, I apologize.
Back to top
tic



Joined: 22 Apr 2007
Posts: 1786

PostPosted: Tue Apr 06, 2010 9:13 am    Post subject: Reply with quote

you should check out the gdi+ library

and look at this post:

http://www.autohotkey.com/forum/viewtopic.php?p=330235#330235
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group