Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How to convert Image data (JPEG/PNG/GIF) to hBITMAP ?


  • Please log in to reply
49 replies to this topic
SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

If I wanted to display two or more images, how would that be done


That would require some work. I expect you to break down the code into proper functions, try it and then post if you are unsuccessful.


the hWndPic1 is not linking in for me, how that is obtained.


That is control Hwnd and the var is allocated on control creation itself, like

Loop 5
 Gui, Add, Text,  w32 h32 +0xE hWnd[color=red]Pic%A_Index%[/color]

You can then SendMessage to Pic1, Pic2, Pic3, Pic4, Pic5

Hope this helps.

:)

Sarah
  • Members
  • 103 posts
  • Last active: Oct 12 2009 05:42 PM
  • Joined: 12 Jul 2007
Ah - thanks for making the function approach clear, I think that should be easy :D (I think)... but it is off to sleep-land for me, and I will attempt to break-apart the functions based on this logic later on. Please have a fantastic rest of your day! ~Sarah

Sarah
  • Members
  • 103 posts
  • Last active: Oct 12 2009 05:42 PM
  • Joined: 12 Jul 2007
Hi there SKAN - I wanted to thank you sooo much for helping me advance this one forward! :D :D :D :D

The one last thing I really had hoped to see this do is to not just display the image on the screen (which is one goal), but to be able to reverse the Text you generate back to the original inputted image.file (or a BMP would be purrfect) ... Can this be done ? :D

hopeful - Sarah

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

to be able to reverse the Text you generate back to the original inputted image.file


FileRead, Hex, [color=red]cat.png.txt[/color] 
nSize := StrLen(Hex)//2 
Hex2Bin( Buffer, Hex ) 

hFile := DllCall( "_lcreat", Str,"[color=red]cat.png[/color]", Int,0 ) 
DllCall( "_lwrite", Int,hFile, Str,Buffer, Int,nSize ) 
DllCall( "_lclose", Int,hFile ) 

Return




  
/* 

  Bin2Hex() and Hex2Bin() 

  Machine code functions: Bit Wizardry [ By Laszlo Hars ] 

  Topic : http://www.autohotkey.com/forum/viewtopic.php?t=21172 
  Post  : http://www.autohotkey.com/forum/viewtopic.php?p=180469#180469 

*/ 

Bin2Hex(addr,len) { ; Bin2Hex(&x,4) 

   Static fun 
   If (fun = "") 
      Hex2Bin(fun,"8B4C2404578B7C241085FF7E2F568B7424108A06C0E8042C0A8AD0C0EA05" 
      . "2AC2044188018A06240F2C0A8AD0C0EA052AC2410441468801414F75D75EC601005FC3") 
   VarSetCapacity(hex,2*len+1) 
   dllcall(&fun, "uint",&hex, "uint",addr, "uint",len, "cdecl") 
   VarSetCapacity(hex,-1) ; update StrLen 
   Return hex 
} 

Hex2Bin(ByRef bin, hex) { ; Hex2Bin(fun,"8B4C24") = MCode(fun,"8B4C24") 
   Static fun 
   If (fun = "") { 
      h:="568b74240c8a164684d2743b578b7c240c538ac2c0e806b109f6e98ac802cac0e104880f8" 
       . "a164684d2741a8ac2c0e806b309f6eb80e20f02c20ac188078a16474684d275cd5b5f5ec3" 
      VarSetCapacity(fun,StrLen(h)//2) 
      Loop % StrLen(h)//2 
         NumPut("0x" . SubStr(h,2*A_Index-1,2), fun, A_Index-1, "Char") 
   } 
   VarSetCapacity(bin,StrLen(hex)//2) 
   dllcall(&fun, "uint",&bin, "Str",hex, "cdecl") 
}

Adapt it accordingly.

:)

Sarah
  • Members
  • 103 posts
  • Last active: Oct 12 2009 05:42 PM
  • Joined: 12 Jul 2007
Thank you.

:razz: