Hi I wonder if anyone can help me. I have a MySQL table that contains a series of hex colour codes and I need to output them to a file. This I can do ok but I need the file to be in a hex format so that when a hex editor opens it reads it correctly. At the moment all I seem to do is create it as a text file then when the hex editor opens it doesn't read it correctly. I hope I've explained myself correctly. The file will be a .act file which will be fed into Photoshop
Any help much appreciated.
outputting a hex file
Moderator: General Moderators
-
TheProgrammer
- Forum Newbie
- Posts: 22
- Joined: Mon Nov 27, 2006 12:25 am
Can't give an estimate on how will work but try getting each hex number (if you have it saved as string, then every letter) and then convert the hex value to decimal, then convert it to the specific character with that code using chr.
Probably like this:
take care there: hexdec takes a string as paramete
Hope it helps. If it does please let me know, I realy am interested if it works. I will probably need this once, but don't have the time to test it now.
Probably like this:
Code: Select all
//do this for each hex number -> for a color do it 6 times
$outputString .= chr( hexdec( $letter ) )Hope it helps. If it does please let me know, I realy am interested if it works. I will probably need this once, but don't have the time to test it now.
feyd | Please use
Thanks for your help.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi
Thanks for that - what I actually had to do was split the hex colour code into the 3 parts - then run the function on that and works great:Code: Select all
$hex=$row['hexcode'];
$r1= substr($hex,0,2);
$g1= substr($hex,2,2);
$b1=substr($hex,4,2);
$outputString="";
$outputString .= chr( hexdec( $r1 ) ) ;
$outputString .= chr( hexdec( $g1 ) ) ;
$outputString .= chr( hexdec( $b1 ) ) ;feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]