Page 1 of 2 12 LastLast
Results 1 to 40 of 56

Thread: Html -> Rgb

  1. #1

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540

    Html -> Rgb

    Ok, I've got this piece of code to convert a color value to HTML coding (it's Delphi code, but it's fairly easy to understand for any VB coder):

    Code:
      iRed := Color and $FF;
      iGreen := (Color and $FF00) div 256;
      iBlue := (Color and $FF0000) div 65536;
    
      Result := '#' + IntToHex(iRed, 2) + IntToHex(iGreen, 2) + IntToHex(iBlue, 2);
    The only differences are that in VB $ = &H and IntToHex() is Hex()...


    Ok, now that works perfectly, but my problem is, I want to reverse it. I've searched half the internet, but couldn't find it. Does anyone know how it works? The code doesn't have to be Delphi code, it can just be VB code...

    Thanks!
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    use the same function

    since html color is bgr, it's just the reverse rgb, so bgr is rgb reversed.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    HTML is RGB, but that's not really what I meant.

    Say I have this value, "#FF0000" (Red), now I want to get the individual RGB values from this, which would be FF, 00 and 00, but how do I convert this to 0-255 range so I would get 255, 0, 0?

    Offcourse I can do it manually with 100 if's, but I hate that
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Illusion

    It looks like it's RGB but in fact the hi byte is in the left end, not the right.

    type

    ?&hff0000

    in immediate window and it'll result, 16711680. the code for blue, not red.

    I'm not familiar with delphi, so you must excuse me. in vb you'd do val("&h" & hexvalue)
    If there's no built in function for this, you don't need too many if's to accomplish the same tasks. loop trough each byte from hi to low, add up the ascii-48 and substract 7 for the range A-F. then you increment the byte pointer and multiply itself with the radix(16)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Mhhhh........I'll go for the if-approach (not good at math)

    But if anyone has some VB code I can understand (I understand things better when I look at code then when someone tries to explain it ), converting it shouldn't be a problem...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    val() function knows what to do but as said i have no idea with delphi. some pseudo for what i was trying to say:
    Code:
    byte x, result y
    loop x from hibyte to lowbyte
    	if x<58
    		y=y+x-48
    	else
    		y=y+x-55
    	y*=16
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Still don't quite understand it, but thanks anyways. I'll work something out...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    just ask if you get stuck
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9
    denniswrenn
    Guest
    Maybe you can convert this to Delphi... It uses quite a bit of If's, but not 100
    VB Code:
    1. Private Sub Form_Load()
    2.     Dim a As Byte, b As Byte, c As Byte
    3.     ToRGB "#FFFFFF", a, b, c
    4.     MsgBox a
    5.     MsgBox b
    6.     MsgBox c
    7. End Sub
    8.  
    9. Private Sub ToRGB(ByVal sHex As String, ByRef bR As Byte, ByRef bG As Byte, ByRef bB As Byte)
    10.     Dim sR As String
    11.     Dim sG As String
    12.     Dim sB As String
    13.     Dim sR1 As String
    14.     Dim sR2 As String
    15.     Dim sG1 As String
    16.     Dim sG2 As String
    17.     Dim sB1 As String
    18.     Dim sB2 As String
    19.  
    20.     sHex = UCase(sHex)
    21.     If Left(sHex, 1) = "#" And Len(sHex) = 7 Then
    22.         sR = Mid(sHex, 2, 2)
    23.         sG = Mid(sHex, 4, 2)
    24.         sB = Mid(sHex, 6, 2)
    25.     ElseIf Len(sHex) = 6 Then
    26.         sR = Mid(sHex, 1, 2)
    27.         sG = Mid(sHex, 3, 2)
    28.         sB = Mid(sHex, 5, 2)
    29.     End If
    30.    
    31.     sR1 = Chr(Asc(Left(sR, 1)))
    32.     sR2 = Chr(Asc(Right(sR, 1)))
    33.     sG1 = Chr(Asc(Left(sG, 1)))
    34.     sG2 = Chr(Asc(Right(sG, 1)))
    35.     sB1 = Chr(Asc(Left(sB, 1)))
    36.     sB2 = Chr(Asc(Right(sB, 1)))
    37.     'RED
    38.     If IsNum(sR1) Then
    39.         bR = (Asc(sR1) - 48) * 16
    40.     Else
    41.         bR = (Asc(sR1) - 55) * 16
    42.     End If
    43.     If IsNum(sR2) Then
    44.         bR = bR + (Asc(sR2) - 48)
    45.     Else
    46.         bR = bR + (Asc(sR2) - 55)
    47.     End If
    48.     'GREEN
    49.     If IsNum(sG1) Then
    50.         bG = (Asc(sG1) - 48) * 16
    51.     Else
    52.         bG = (Asc(sG1) - 55) * 16
    53.     End If
    54.     If IsNum(sG2) Then
    55.         bG = bG + (Asc(sG2) - 48)
    56.     Else
    57.         bG = bG + (Asc(sG2) - 55)
    58.     End If
    59.     'BLUE
    60.     If IsNum(sB1) Then
    61.         bB = (Asc(sB1) - 48) * 16
    62.     Else
    63.         bB = (Asc(sB1) - 55) * 16
    64.     End If
    65.     If IsNum(sB2) Then
    66.         bB = bB + (Asc(sB2) - 48)
    67.     Else
    68.         bB = bB + (Asc(sB2) - 55)
    69.     End If
    70. End Sub
    71.  
    72. Private Function IsNum(sNum As String) As Boolean
    73.     If Len(sNum) <> 1 Then
    74.         IsNum = False
    75.     ElseIf Asc(sNum) >= 48 And Asc(sNum) <= 57 Then
    76.         IsNum = True
    77.     End If
    78. End Function

  10. #10

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Thank you!! That worked great!

    I know this is a VB forum (really? I didn't even notice that? Wow... ), but here's the Delphi code anyways for anyone interested:


    Code:
    function IsNum(Value: Char): Boolean;
    begin
      // Check ASCII value
      if (Ord(Value) >= 48) and (Ord(Value) <= 57) then
        Result := True
      else
        Result := False;
    end;
    
    function ConvertValue(Value: String): Byte;
    var
      bResult: Byte;
    
    begin
      // Check first character
      if IsNum(Value[1]) then
        bResult := (Ord(Value[1]) - 48) * 16
      else
        bResult := (Ord(Value[1]) - 55) * 16;
    
      // Check second character
      if IsNum(Value[2]) then
        bResult := bResult + (Ord(Value[2]) - 48)
      else
        bResult := bResult + (Ord(Value[2]) - 55);
    
      Result := bResult;
    end;
    
    function HTMLtoRGB(HTML: String): TColor;
    var
      sHTML: String;
      sR,
      sG,
      sB: String;
      bR,
      bG,
      bB: Byte;
      iOffset: Integer;
      iLength: Integer;
    
    begin
      // #ff0000 -> #FF0000 (necessary for ASCII operations)
      sHTML := UpperCase(HTML);
    
      // Check length
      iLength := Length(sHTML);
    
      if (iLength < 6) or (iLength > 7) then begin
        Result := 0;
        exit;
      end;
    
      if (sHTML[1] = '#') and (Length(sHTML) = 7) then
        iOffset := 2
      else
        iOffset := 1;
    
      // Get RGB values (using the 'string = array' rule)
      sR := sHTML[iOffset] + sHTML[iOffset + 1];
      sG := sHTML[iOffset + 2] + sHTML[iOffset + 3];
      sB := sHTML[iOffset + 4] + sHTML[iOffset + 5];
    
      // Convert RGB values
      bR := ConvertValue(sR);
      bG := ConvertValue(sG);
      bB := ConvertValue(sB);
    
      // Return color
      Result := RGB(bR, bG, bB);
    end;
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  11. #11
    denniswrenn
    Guest
    Wow, I must say, that is one effed up language

    I'd prefer C++ anyday

    Any particular reason you're coding in delphi rather than something like C++?(just curious)

  12. #12

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Well, there are some reasons why I moved from VB to Delphi, and some why I didn't choose C++.

    First of all, Delphi looks more like VB than C++. I initially did start to learn C++, created a DLL, but it takes a lot of code to create a window (unless you're using MFC, but that would still require a DLL, and that's the main reason I stopped using VB ). Delphi however still has the possibilities to create a Window using pure API, but also has a lot of standard components which are merged with the EXE (resulting in a 300 KB EXE file, but that isn't really that bad compared to the at least 2 MB of runtimes which VB needs)... but I created an OpenGL application recently which did create a window using only API, and it turned out to be 20 KB

    Also, Delphi's IDE takes more time to load, but compiling a program is done within seconds (and that's on my P133 )...

    And last but not least, the speed of Delphi compared to the speed of C++ is not that much. I wouldn't say it's just as fast, but it comes close... and if that's not enough, Delphi also supports inline assembly...

    Now looking at the speed at which the programs run in both languages, compared to the time it takes to produce such a program, that made me choose Delphi...


    (oh, and the help files which come with Delphi are incredible!! they're huge!! not only the Delphi help is included, but also a lot of MS SDK help files, like all the API function and OpenGL reference)
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  13. #13

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    "Wow, I must say, that is one effed up language"

    What did you mean with that anyways?
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  14. #14
    denniswrenn
    Guest
    Well, you can use dialog's in C++.... MSVC++ has a dialog editor... it's like creating something in VB or Delphi(it's visual), but it results in an executable that is still horrifyingly small

    But, I don't really like using dialogs... CreateWindowEx ==

  15. #15
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Delphi looks much like pascal right? (begin and end everywhere) Isn't it even to pascal something VB to basic?
    Originally posted by PsychoMark
    Delphi however still has the possibilities to create a Window using pure API, but also has a lot of standard components which are merged with the EXE (resulting in a 300 KB EXE file, but that isn't really that bad compared to the at least 2 MB of runtimes which VB needs)
    Yeah, you can do that in VB too, I remember making a unattended execution dll which used createwindowex. The VB runtimes are part of windows scripting so there's no need to include them in your package. Anyways, C++ horrifying small executables rock
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  16. #16

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    1. Delphi = Object Pascal + VCL (Visual Components Library, all the controls which are merged with the EXE)

    2. VB can do that, but it would still require the runtime DLL's. Even though the runtimes are included with the OS more often, users running for example Win95 would still need them... (and I must say that the AddressOf thing in VB isn't exactly the most stable )

    3. Yeah, offcourse C++ is the king when it comes to small executables and high speeds, but like I said, I don't want to spent 20 minutes just to add a textbox...


    4. I don't hate C++ or anything, I think it's a great language! It's just not my primary language...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  17. #17
    denniswrenn
    Guest
    *ahem*

    >>>>Well, you can use dialog's in C++.... MSVC++ has a dialog editor... it's like creating something in VB or Delphi(it's visual), but it results in an executable that is still horrifyingly small <<<<

  18. #18

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Oops, didn't notice that one... anyways, I still like Delphi a little bit more
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  19. #19
    denniswrenn
    Guest
    Originally posted by PsychoMark
    "Wow, I must say, that is one effed up language"

    What did you mean with that anyways?
    effed = fed = f***ed

    Was just kidding though Well, kind of; pascal is wierd..

  20. #20
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Smile I knew it, those := was looking very pascalish to me

    I agree with dennis, pascal is weird, but i've heard it's a very nice and well structured language. Can you use pointers? With Object Pascal, do you mean the objects are all COM? Is it ActiveX compatible?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  21. #21

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Well, I don't think it's weird, but that's just a matter of getting used to it....

    It is in my opinion very well structured. The way the objects are built, it's very well done. Delphi does support Pointers (really supports, not like VB). Delphi also supports COM and ActiveX, but I don't think that's what they mean with Object Pascal. I think it has something to do with the structure of the objects, they all use a base class which they inherit properties from. You can do some nice things with that btw...

    Delphi also supports things like overloading functions, built-in message handling support (just add 'message WM_PAINT' for example after you've declared a function, and it reacts to it.... at least when you declare it in a form), and inline assembly (I already mentioned that, didn't I? )

    Name something that can be done in C++, and I'll bet it can be done in Delphi too...



    Oops, one thing I like about C++: "X++" or "X *= 40". Delphi doesn't support that . It does however has the "Inc(X)" function for integers, which the compilers optimizes a lot more than "X := X + 1"...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  22. #22

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    *looks at the other thread of denniswrenn*

    ...and Delphi also support threading, both using the API and the supplied TThread objecty
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  23. #23
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Sounds very nice, if you compare to vb6. templates? if not inheritance and polymorphism i guess templates. Inline asm sounds good, but other than that the variety of operators, some low level ones not only ++ and assignment operators, what about bitshifting (<< >> <<= >>=)? and operator overloading, maybe a bit unnessesary but cool feature, you can actually replace all methods and go wild on polymorphism with object only programming Is there a preprocessor in object pascal? You know #include #define and company Further on inheritance, multiple inhertinace? virtual inheritance? virtual functions? what about type structures, can they functions as objects like in c++, and I don't mean COM ones.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  24. #24

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Wow, that's a lot of questions. Actually I don't really know, I've only worked with Delphi for about a month now, and I'm not really doing things like bitshifting

    You should check out borland.com or something for those kind of questions, I just know I like Delphi and that it can do a lot more than VB at a much higher speed
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  25. #25
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    maybe, or maybe i'll stay with c++. pascal just looks weird
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  26. #26
    denniswrenn
    Guest
    C++ Rules..!

    But I installed Delphi anyway(free copy of Ver. 4 standard with C++ Builder 5 pro) just incase garfield needs help


  27. #27
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Hey, I have a question: what do you think is better, C++ or ASM?

    Because I wanna learn one of them but I don't know which; also I don't know where to start learning it
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  28. #28

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    I think C++. It's fast enough, allows for more rapid development, but still allows ASM to be used in case speed is really the top priority...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  29. #29
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++!
    BURN IN HELL ALL NON-C++ USERS!!!!! BWAHAHAHAHAHAHA

    I hate Pascal I don't like the way it has keywords for things you don't need (begin/end) and also the separation of variables from code is nasty.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  30. #30

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Is Parksie trying to make a point?



    (burn in hell all you "burn in hell people who don't use [your language here]" !! )
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  31. #31
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Me? Point? Naaaaahhhh
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  32. #32
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Originally posted by parksie
    C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++! C++!
    BURN IN HELL ALL NON-C++ USERS!!!!! BWAHAHAHAHAHAHA

    I hate Pascal I don't like the way it has keywords for things you don't need (begin/end) and also the separation of variables from code is nasty.
    exactly, being and end all the time instead of {} makes you sick C++ for the real pro's, VB for kids and pascal for other weirdos
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  33. #33
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    The neat thing with C++ or C is that you can really strip it down to the bare limit - you can get a 32-bit C program in under a kilobyte by using no standard libraries and implementing all the code yourself (including _mainCRTStartup).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  34. #34
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Hehe I tricked you all, I've been learning ASM for a long time to optimize my special effects module (it's getting kinda hard now hehe) and it rocks, check this out
    Attached Files Attached Files
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  35. #35
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Btw look at the size of the EXE, it's HIGHLY optimized!
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  36. #36

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Originally posted by kedaman
    exactly, being and end all the time instead of {} makes you sick C++ for the real pro's, VB for kids and pascal for other weirdos

    Well, in that case I'm a weirdo!

    To Jotaf98, can you post the code used to do the messagebox?

    I tried to get a program as small as possible in Delphi too, it turned out to be 16 kb (mainly because of the System unit Delphi automatically adds), but at least the code was readible:

    Code:
    program msgbox;
    
    const
      { MessageBox constants }
      MB_OK = $00000000;
      MB_ICONINFORMATION = $00000040;
    
    { MessageBox API }
    function MessageBox(hWnd: LongWord; lpText, lpCaption: PChar; uType: LongWord): Integer; 
        stdcall; external 'user32.dll' name 'MessageBoxA';
    
    begin
      MessageBox(0, 'Delphi kicks ass!', ':p', MB_OK or MB_ICONINFORMATION);
    end.

    (btw, the program to color the code, made that in Delphi, took me 2 hours, including preview option and nice looking interface, now try that in ASM )



    Btw, where did you learn ASM? Since Delphi supports the 'asm' keyword, I would sure like to try it out some time...



    [edit] note to self: add line-break option for code [/edit]
    Last edited by PsychoMark; Jul 10th, 2001 at 02:00 AM.
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  37. #37

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540

    Thumbs down

    Oops, nevermind the "I want to learn ASM part"...


    Just looked at a tutorial to show a MessageBox... *runs away screaming and pulling his hair out*



    I'll stick with Delphi for a while
    (just finished my first OpenGL test, OpenGL rules!! )
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  38. #38
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Hehe, in fact, that's the program that comes with the sample winzip file, modified a bit with my Hex Editor

    Do you know any good books about C++? Whenever someone reccomends me a book, someone else says that book s*cks...

    And the only part that I wanna learn is DLLs and dynamic 2 and 3 dimensioned arrays
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  39. #39
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    If that's the only thing you want to learn, that's probably not where you'll end up.
    There's no built in "arrays" in C++, you use pointers, and you'll learn to love them or you'll just quit C++. There are of course array classes but I think they suck. exporting DLL functions shouldn't be that hard, in fact that was the first thing I wanted to do when I started C++ and now it's the last thing I want to learn

    I still do recommend Sam's teach yourself C++ in 21 days, it took about 5 days for me to read trough.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  40. #40

    Thread Starter
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    *cough* Delphi *cough*



    Well, actually, that's exactly what I wanted to use C++ for too. I only looked at the sample at DirectX4VB, and did get it working, but that's about it... still addicted to pointers though

    I did download a tutorial for C++ (CyberCarsten's site if I'm correct), which wasn't specifically about DLL's and arrays, but it does help learning the language, so I'll go with kedaman's advice...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width