Hi All!! Long time browser, first time poster here.
I am normally quite content to expand my brain simply by browsing through this site but I have a question that, despite my best efforts, I cannot figure out. So I am hoping that someone can do it for me.
I am trying to teach myself programming and i’ve started with VBA as it is easy.
I have made a program that explores the mandelbrot set and have so far been quite successful. Problem is I have to display the result in excel and assign a cell color depending on the escape velocity. If you make all the cells square and zoom right out it looks OK but is very slow. I now want to have my program come up with a bmp instead. I get how the format works but I can’t get VBA to do it. I’ve thought about creating a text file with all the required hexidecimals in the right order and then using a hex editor to paste them into a blank bitmap but the problem is I can’t find a hex editor that will let me copy “FF 00 00 etc” from notepad and paste it into the hex editor to achieve the desired result.
Can anyone think of a way to do this or perhaps, even better, get vba to edit a bitmap directly.
Or maybe it’s time I start learning a new language…
Hexadecimal is just another way of expressing numbers. What your bitmap requires is bytes whose values - numbers - are often expressed in hex just because it is a convenient notation. I don’t know VBA at all but most programming languages will have some mechanism to write bytes directly, often a Byte data type. Just assign the number you want to a byte and write it directly to the bitmap file.
It sounds like you are getting VBS to write the characters F, 0 etc. to a text file, i.e. the ASCII/Unicode codes for them. So in the case of F you are actually writing the number 70 (decimal, or 46 in hex) to the file. What you need to do is write the values F (15 in decimal), 0 etc. to the file, i.e. you should open it as a binary file.
ISTR that the syntax in VB is something like Open <filename> As Binary. Then you can Put, or whatever the syntax is, the contents of numeric variables directly to the file.
Thanks X,
I think you’re on to something about opening in binary.
I should be able to work it out from here.