I needed a random color selector. I found one [here](http://peepspower.com/python-script-to-generate-random-css-colors). I rewrote it to make it more general purpose. "f_GenRandomColor" is the picker. The output is in list form, which should make it suitable for most general applications. "f_HTMLRandomColorChart" is just a way to create an HTML table to test the output from. Thanks to the original author.

Member Avatar
Member Avatar
+2 forum 1

## Background ## Hi All, I 've been playing around with colour (color!) formats and needed to create a class for converting different formats, so I thought I'd share it. It seems to work quite well and accepts a number of different convenient formats. The class allows the conversion between HSL, HSV, RGB, CMYK, HEX (base16), Integer (base10) and 'HTML color names'. I found the formulae for conversion from pseudocode in the following locations: http://www.rapidtables.com/convert/color/ (great colour references!) http://stackoverflow.com/questions/15202079/convert-hex-color (for the sscanf method) It should be noted that conversions involving CMYK can only be approximate as there is no absolute …

Member Avatar
Member Avatar
+5 forum 4

I have this string " țara " which contains a character ț which is stored on 2 bytes. When i do in linux : hexdump -C file that contains the string it shows : 00000000 c8 9b 61 72 61 |..ara| 00000005 It is normaly to view c8 and 9b ? This isn't the code point in hex of ț . When we take the same string and put it here : [txt_to_hex](http://software.ellerton.net/txt2bin/) We get : 021b 61 72 61 Where 021b is the code point of ț showed in hexa. Why does hexdump shows a wrong result ? c8 …

Member Avatar
Member Avatar
+0 forum 1

Hi everyone, I am new here and I hope all of you are doing well. I have spent the whole day searching around on the almighty Google for code that can help me with my problem. In the following code there may be quite a few n00b mistakes, and for these I apologize, since I have not done coding in C in ages. So, firstly I will try and explain what I need to do as best I can, before dumping eye-watering code: My Objective: I need to convert a String, ie: "Hello World!" (<- why did this ever became …

Member Avatar
Member Avatar
+0 forum 3

Hi, I want to convert a float value to 32bit hex and the code I have right now returns 64bit hex. The float is stored in a string called value. [CODE] result = Convert.ToDouble(value); long lVal = BitConverter.DoubleToInt64Bits(result); string hex = lVal.ToString("X"); OutputBox.Text += ("\nConverted the " + value.GetType().Name + " value '" + value + "' to the " + hex.GetType().Name + " value " + hex + ".");[/CODE] Example output: Converted the String value '-2.07217' to the String value C00093CDDD6E04C0. How would I do this?

Member Avatar
Member Avatar
+0 forum 4

I am trying to read a structure from a .dat file...the first integer to be read is the no of readings, then there is the data in following structure format struct Oven { int rec_no; int temp; int status; char string[10]; }; below is the method through which I read the file int read_and_process_file() { int counter; FILE *ptr_myfile; FILE *ptr_myfile2; struct Oven my_record,my_record2; ptr_myfile=fopen("data.dat","rb"); ptr_myfile2=fopen("out.csv","w+"); if (!ptr_myfile) { printf("Unable to open file!"); return 1; } fread(&no_of_readings,sizeof(no_of_readings),1,ptr_myfile); int value=10; unsigned char x; for ( counter=1; counter <= 2570; counter++) { int size = fread(&my_record,sizeof(struct Oven),1,ptr_myfile); if (size != 1) { …

Member Avatar
Member Avatar
+0 forum 3

please any one can help me about send and recieve packets by serail port the pakeck that i need to send is in hex to controll some thing how can do this in vb.net how can do like this design in the picture below please help me

Member Avatar
Member Avatar
+0 forum 1

I need to remove a certain color, like for example, 0xFFFFFF (Color.White) would remove all the white in an image. Thanks :)

Member Avatar
Member Avatar
+0 forum 4

Ok. As the title says I tried many times to simply write a program that rewrites a file to remove null characters. I confirmed with a hex editor that the file in question has tons on null characters, on average about 1 of every 2 characters in null. So my last attempt: #include <stdlib.h> #include <stdio.h> int main() { FILE *f = fopen("main2.c","r"); FILE *t = fopen("temp","w"); int c; int count = 0; while((c = fgetc(f))!=EOF) { if(c) { fputc(c,t); } else { printf("null found\n"); } } fclose(f); fclose(t); FILE *n = fopen("main2.c","w"); FILE *w = fopen("temp","r"); while((c=fgetc(w))!=EOF) { fputc(c,n); …

Member Avatar
Member Avatar
+0 forum 10

Hi everyone I'm stuck on a school project. The Following is the prompt: > Write an assembly language program that prompts the user to enter a string to be interpreted as an 8-digit hexadecimal number. Your program must convert the ASCII string representation of this hexadecimal number into a 32-bit unsigned binary number. Then, your program must prepare and store an ASCII string for the octal (base 8) representation of the same number and print it out.Your program should generate an error if the input string contains a character that is not 0 through 9 or A through F (except …

Member Avatar
+0 forum 0

i have a function in a module that requries integer values. these values are set by the user typing in two textboxes on the form. the texboxes contain Hexadecimal data in string form. function: Friend Function addNewCode(ByVal Location As Integer, ByVal Opcode As Integer) As Boolean If (Not LocStack.Count < 1000) Then Form1.TextBox1.AppendText(vbCrLf) Form1.TextBox1.AppendText("Cannot add new code. No room Left in queue!") Return False Else LocStack.Push(Location) opcStack.Push(Opcode) Form1.TextBox1.AppendText(vbCrLf) Form1.TextBox1.AppendText("Added New Code " & Hex(Location) & "-" & Hex(Opcode) & " in queue slot " & LocStack.Count - 1 & "!") End If Return True End Function and is called when …

Member Avatar
Member Avatar
+0 forum 1

I am developing a website in which i am showing the hexa code into bgcolor of td of table. The problem is that when someone like that page or print the page then that color is not showing because the color is bgcolor color of td. So, i want to convert hexa code into images. My Hexacodes(2000) are saved in database. How i will convert these hex codes into images in ASP.Net, C#. Please guide me.

Member Avatar
Member Avatar
+0 forum 1

I have a string of text being sent through a serial port to a text box (Text1.Text). The string has some symbols in in which I am assuming are Hex values. The hex values are Hex(1), Hex(4), Hex(12), and Hex(17). What I need to do is find the position of these hex symbols in the string of text so that I can split or grab the data after the specific hex symbol. I am not able to use substring or indexof or instr ... or at least I am not using it correctly to find the appropriate symbol. I was …

Member Avatar
Member Avatar
+0 forum 1

Hi all, I'm sure this is a n00b question, but I can't seem to get my head around it! I have a 4 BYTE array which I want to display as a decimal value. For example, in the array it contains the hex values: 00 05 7d a4, and I would like to display 359,844. Any clues on how I go about this? I have tried: BYTE freeBlocks[4]; memcpy(freeBlocks, trackInformation + 16, 5); _tprintf(_T("%u"), strtoul((char*) freeBlocks, NULL, 16)); But this only prints out 0. I know freeBlocks contains the correct values as when I do: for(int i; i < 4; …

Member Avatar
Member Avatar
+0 forum 2

Let me start off by saying that this is homework, and I have most of it completed. However, I am stuck on how to convert decimal to hexadecimal. The assignment is to add two hexadecimal numbers and output the answer. If the length of the answer is greater than 10 digits, then output "Addition Overflow." I've completed the conversion of the two strings to decimal and added them together, now I think that I need to convert the answer back to a string. I know it's long, but if you would take the time to read my code, then it …

Member Avatar
Member Avatar
+0 forum 42

I'm writing a program to add two hex numbers of up to ten digits, and I'm recieving an "assertion failure," and I can't figure out why. Any help would be greatly appreciated. Thank you for you time! [CODE] // hex addition.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <string> #include <cmath> using namespace std; void convertToDec(string, string); int _tmain(int argc, _TCHAR* argv[]) { //assign values to last six hex characters //convert both inputs to dec //add two dec numbers //convert back go hex for answer string input; string input2; string hex[16] = …

Member Avatar
Member Avatar
+0 forum 7

Hello I have a sequence that looks like this: 60211401dc070000 which is a string (it was build through a series of concatenations and conversions) How can i just tell him that it is actually a hex ?? without modifying it's value... Thanks! Have a nice day

Member Avatar
Member Avatar
+0 forum 5

Hello, I'm trying to represent the system date in a sequence such as: dd mm yy yy So far i got: dd mm yyy so, the year is represented on 2 ytes, but I only have 3 characters, i need to split after the first character and then add a zero in from of the first character. for example 2012 in hex = 7dc I need to turn it in 07 DC I could not find anything regardin spliting without a separator... Any help is apreciated :)

Member Avatar
Member Avatar
+0 forum 1

I have a problem when adding 2 numbers in assembly because we are using hex. When add 4+5 (34h + 35h) the output is 9 but if I add 5+5 (35h + 35h) the output displays colon(:) or 3ah instead of 10. Here's the sample image when i generate the code. [IMG]http://i42.tinypic.com/35hpkhs.jpg[/IMG] Here's my code. Run>debug 5+4 = 9 [CODE]a100 ;assemble mov ah,02 mov ch,35 ;5 mov cl,35 add cl,ch ;5+5 sub cl,30 ;-30 mov dl,cl int 21 int 20 g[/CODE] Adding 5 + 5 = : [CODE]-a100 mov ah,02 mov ch,34 ;4 mov cl,35 add cl,ch sub cl,30 mov …

Member Avatar
Member Avatar
+0 forum 1

Hi, Is it possible to take the input from a textbox that's in chinese (unicode) and convert it into hex to output to a text file? Any insight would be great, thanks!

Member Avatar
Member Avatar
+0 forum 3

Hello software developers :) I've decided to try and "crack" a (very simple) program I've written myself, just for the sake of it. Here's the code: [CODE] #include <stdio.h> const int serialCode = 255; int guess; int main() { printf("Please enter your serial code: "); scanf("%d", &guess); if(guess == serialCode) { printf("Thank you for CRACKING this software!\n"); return 0; } printf("YOU FAILED!\n"); return 0; } [/CODE] I would like it to be so that once you've submitted your guess, it'll skip the validation and just tell you that you've got it right, right away. This is the disassembly generated by …

Member Avatar
Member Avatar
-1 forum 5

I'm trying to convert hexadecimal values to Binary. I've done Decimal values to Binary up to 32 bits in this way: [CODE] #include <stdio.h> int showbits(int);/**************function*prototype******************************/ int main() { unsigned int num; printf("enter the number."); scanf("%d",&num); printf("%d in binary is ",num); printf("\n"); showbits(num);/*********************function*call********************************/ return 0; } showbits (int n)/******************function*definition****************************/ //* { int i,k,andmask; for(i=31;i>=0;i--) { andmask = 1<<i; k=n&andmask; k==0?printf("0"):printf("1"); } } [/CODE] Now I wan't to add hexadecimal values in it.

Member Avatar
Member Avatar
+0 forum 4

Hi all, I am trying convert IP addresses form Decimal format [Like 192.168.12.13] to HEX format [c0 a8 9d 80]. For Example the IP "192.168.157.128" is equivalent to "c0 a8 9d 80" in HEX. How to do that.??

Member Avatar
Member Avatar
+0 forum 2

Hi, This is probably in the wrong place but I've looked everywhere for help, and nothing yet. I have a game save for an indie game, and I'm trying to edit the amount of coins I have. The method I have tried hasn't worked and I'm unsure why. Here was my method: 1) Open the game save in HxD (or a hex edit program) 2) Assuming I have 10000 coins, search for the integer 10000 3) This will highlight the hex value for 10000 4) Then replace this value with something like 30000 5) Rehash & Resign the save 6) …

Member Avatar
Member Avatar
+0 forum 1

Need help converting from hex to binary any help is very appreciated!! [CODE]#include <string> #include <iostream> class Hex { private: //constructor std::string hexNumber; int decNumber; public: Hex(std::string hNum): hexNumber(hNum) {} Hex(int dNum): decNumber(dNum) {} ~Hex(); int toInt(); std::string toBin(); std::string toHex(); }; [/CODE] it keeps saying i need to put a semicolon before the period on line 23 not too sure exactly where its talking about or maybe i did something wrong. [CODE]#include <iostream> #include <string> #include <sstream> #include "hex.h" Hex::~Hex() //destructor { } int Hex::toInt() { int num; std::stringstream toBeConverted(hexNumber); toBeConverted >> std::hex >> num; return num; } std::string …

Member Avatar
Member Avatar
+0 forum 6

hi, i have a script that converts hex to bin and bin to hex back. however, when converting back to hex the leading 0s are truncated. how to maintain the leading 0s? i'm using Python 2.5 and Win XP. tq [CODE] import binascii import string def byte_to_binary(n): return ''.join(str((n & (1 << i)) and 1) for i in reversed(range(8))) def hex_to_binary(h): return ''.join(byte_to_binary(ord(b)) for b in binascii.unhexlify(h)) def bintohex(s): return ''.join([ "%x"%string.atoi(bin,2) for bin in s.split() ]) array0 = '000a00000003c0000030000c1f800000' a=hex_to_binary(array0) print "Convert array0 to bin:",a print "Convert array0 back to hex:",bintohex(a) if bintohex(a)==array0: print "Match" else: print "Not match" …

Member Avatar
Member Avatar
+0 forum 5

I am to write a program that converts either binary, hex or octal to decimal. We are to use methods for the first time (Not a problem). I have written almost all of the code but the conversion. We can't use int.toDecimal or any shortcut. All must be long coded so that we learn something from the process. I have looked for the past 3 days trying to find the answer to how this should be accomplished and have found nothing. My question is how to take an input of either an integer or string and output it in one …

Member Avatar
Member Avatar
+0 forum 23

I have two codes in C and in Python. They gave me different results. Can anybody explain how they works, why I get different results? Thank you in advance!!! In C: ----------- #include <stdio.h> int main() { int a = 100; printf("%d = %02x\n", a, a); a = ~a; printf("%d = %02x\n", a, a); return 0; } OUTPUT: 100 = 64 -101 = ffffff9b In Python: ----------- a = 100 print("%d = %02x"%(a,a)) a = ~a print("%d = %02x"%(a,a)) OUTPUT: 100 = 64 -101 = -65

Member Avatar
Member Avatar
+1 forum 1

Hi, i am working on a project that involves converting 8-bit hex numbers into integer. Firt, I have to say that my hex number is not a number right now, it is only a bunch of characters. for example: int d; char code[9]; code="FFFFFF01"; d=strtol(code,NULL,16); when I try to printf intger d, it never gives me negative numbers. Anyone has any idea? Thanks in advance. Fatih

Member Avatar
Member Avatar
+0 forum 7

Hi there, it's me again. My last post isn't even solved yet but already i'm on a new job, of which i'm not very proud. This time i need to convert the hex codes i put in a textbox as a string like this: "55 00 01 61 07 46" and they should come out as a line of bytes, ready to send over a serial port. Unfortunately i've lost track when i tried to tell VB it's hex codes i put in the textbox. Can someone please give me a little hint on this, like how to tell vb …

Member Avatar
Member Avatar
+0 forum 1

The End.