Announcement

Collapse
No announcement yet.

Help with converting images?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with converting images?

    What I wish to be able to do is to write a program that converts
    a BMP, GIF, JPG, or JPEG file an icon (.ICO). I have pored over
    the Win32Api Help file, and the API routines for images, etc.,
    overwhelms me, and I have not been able to find a clearcut
    algorithm for achieving my goal. I would like to be able to
    convert the images to ICO's with support for up to 96x96 pixels
    and True Color color depth. Naturally, lesser settings would
    also have to be supported.

    Can anybody please give me the sequence/names of the API calls
    to use to accomplish this? Do NOT include example code, as THAT
    much I can figure out myself, please.

    Thanks in advance!

    Clay Clear


    ------------------
    Head SysOp/Owner
    Clear's Critters BBS
    Node 1: (218) 229-2593
    Node 3: (218) 229-2353

  • #2
    OK, I believe I've found the API calls I need for manipulating
    bitmaps in the Win32Api Help file. But, for my final question
    on this topic: does anybody know how to save a converted bitmap
    into ICO format as a file on the HD? I have NO clue as to the
    struct format for an icon.

    Thanks in advance!

    Clay Clear


    ------------------
    Head SysOp/Owner
    Clear's Critters BBS
    Node 1: (218) 229-2593
    Node 3: (218) 229-2353

    Comment


    • #3
      Try here: http://www.wotsit.org/

      ------------------
      Tom Hanlin
      PowerBASIC Staff

      Comment


      • #4
        Thanks a million, Tom! That URL you passed to me had the info I's
        looking for. <smile> In fact, that website is so jampacked with
        info, I bookmarked it for many future visits. In fact, once
        I write/debug my bitmap-to-icon converter program, I'm going
        to write a program that strips MP3's of their ID Tags - there
        is a plethora of requests for such a program on the Napster
        and Syntrillium Forums. I'll be able to do that because I also
        saw a file (or link? don't recall for sure) that provides the
        specs for MP3 files. You've opened new horizons for me by
        the simple passing of that URL!

        Of interesting note is that, the structs within an ICO file
        follow those of the ICONINFO and ICONHEADER(?) structs. And,
        the help file I found on the site details the order and nature
        of each of the datum's in the ICO file. The only drawback is
        that the help file was written back when Win95 were the
        new-kid-on-the-block. So, will have to experiment with it a bit.

        Anyway, sorry for the long conversation. Thanks, again, Tom!

        Clay Clear


        ------------------
        Head SysOp/Owner
        Clear's Critters BBS
        Node 1: (218) 229-2593
        Node 3: (218) 229-2353

        Comment


        • #5
          OK, I'm now experimenting with GetDIBits(). The problem is, I
          get a compiler error when it comes to the line that actually
          runs the code. The error says, "Variable expected"

          The line I'm using is:

          CF3 = GetDIBits(HDC&,CF2,1,96,%NULL,y,%DIB_RGB_COLORS)

          y is declared as follows:

          TYPE BITMAPINFO


          ------------------
          Head SysOp/Owner
          Clear's Critters BBS
          Node 1: (218) 229-2593
          Node 3: (218) 229-2353

          Comment


          • #6
            Sorry, pressed the wrong keys when posting my last message.

            OK, I'm having problems with GetDIBits(). My PBDLL6.0 compiler
            generates the error message "Variable expected" when coming to
            the line that runs it. The following shows how I call the
            routine:

            CF3 = GetDIBits(HDC&,CF2,1,96,%NULL,y,%DIB_RGB_COLORS)

            Note that CF* variables are declared in my custom INC file as
            LONG's.

            y is defined as follows:

            TYPE BITMAPINFO
            z AS BITMAPINFOHEADER
            x(5000) AS RGBQUAD
            END TYPE
            GLOBAL y AS BITMAPINFO

            Then, in a line before I call the function, I have:

            y.z.biBitCount = 0

            Could it be that WIN32API.INC DECLARE's the function
            inappropriately? Or am I misusing the y TYPE?

            Thanks in advance!

            Clay Clear


            ------------------
            Head SysOp/Owner
            Clear's Critters BBS
            Node 1: (218) 229-2593
            Node 3: (218) 229-2353

            Comment


            • #7
              Clay,

              Why did you redefine a standard windows type (aka structure)?
              The BITMAPINFO type in the win32api file does not match
              your description.

              From the API:

              Code:
              TYPE BITMAPINFO
                bmiHeader AS BITMAPINFOHEADER
                bmiColors AS LONG
              END TYPE
              The GetDIBits function is expecting the udt in the above format.
              Your second element is typed as an array of rgbquads, not a long
              as the standard udt calls for. Did you include this udt after
              including the API and thus overridding it?

              Cheers,
              Cecil

              ------------------


              [This message has been edited by Cecil Williams (edited April 18, 2001).]

              Comment


              • #8
                Cecil,

                I have done it before where I've redefined structs that were
                already defined in the WIN32API.INC, without any problems.
                However, I'll try your suggestion. You could be 100% on-target
                with your questions, as I am finally at a loss for getting the
                line to compile.

                Also of note is, I just printed out some source code from
                another posting in this Forum that uses GetDIBits, and I noticed
                that the poster uses VARPTR for one of the FUNCTION's parameters.
                So, I am going to try that FIRST. If it doesn't make it work,
                then I'll apply your thoughts.

                Thanks for your reply!


                ------------------
                Clay C. Clear

                Head SysOp/Owner
                Clear's Critters BBS
                Node 1: (218) 229-2593
                Node 3: (218) 229-2353

                Comment


                • #9
                  OK, I tried *both* ideas, Cecil's and the format posted by the
                  other member, and I still get compiler error 426, "Variable
                  Expected" when I try to compile it.

                  Anybody have any other ideas?


                  ------------------
                  Clay C. Clear

                  Head SysOp/Owner
                  Clear's Critters BBS
                  Node 1: (218) 229-2593
                  Node 3: (218) 229-2353

                  Comment


                  • #10
                    The error message should tell you where the variable is expected,
                    which should do much to help solve the problem...

                    Many "types" used by Windows are really more like pseudo-code. You can't
                    use them as is, because they have variable-length portions where the length
                    "depends". So, it is not necessarily wrong to redefine an API UDT for your
                    own purposes.

                    ------------------
                    Tom Hanlin
                    PowerBASIC Staff

                    Comment


                    • #11
                      Got it working! I did it by using Cecil's ideas, the VARPTR for
                      one of the FUNCTION's parameters, and, the final fix, by using
                      BYVAL with ALL of the FUNCTION's parameters.

                      I'm sure I'll be posting MANY new questions as I continue to
                      learn how to manipulate images using API Calls. I am a pure
                      novice at such stuff, as I've never tried it before. As stated
                      in my original posting, I am trying to develop a program that
                      will convert a bitmap to an icon.

                      For those of you who are also interested in doing so, there is
                      a file on http://www.wotsit.org/ that explains in detail the
                      structure of an ICO file. That will help me invaluably in
                      writing the final code to my program. Keep in mind, though,
                      that the file were written when Win95 was at the top.



                      ------------------
                      Clay C. Clear

                      Head SysOp/Owner
                      Clear's Critters BBS
                      Node 1: (218) 229-2593
                      Node 3: (218) 229-2353

                      Comment


                      • #12
                        I am at a TOTAL loss with the GetDIBits API Call! No matter
                        WHICH Bitmap I use, it ALWAYS returns the biColrsUsed as 0,
                        the biBitCount as 32, and biCompress as BI_BITFIELDS. It even
                        does it on bitmaps that I *know* have a color depth of only 57!
                        (600x600x256). In other words, it's reflecting what my Windows
                        Display settings are, NOT what the bitmaps' settings are!

                        I think it might be because I'm using:

                        hDC = GetDC(%HWND_DESKTOP)

                        But, I don't know of any other method to get a DC for a bitmap
                        loaded with LoadImage(). Can anybody help me with this,
                        PLEASE???

                        Thanks!


                        ------------------
                        Clay C. Clear

                        Head SysOp/Owner
                        Clear's Critters BBS
                        Node 1: (218) 229-2593
                        Node 3: (218) 229-2353

                        Comment


                        • #13
                          Originally posted by Clay Clear:
                          Got it working! I did it by using Cecil's ideas, the VARPTR for
                          one of the FUNCTION's parameters, and, the final fix, by using
                          BYVAL with ALL of the FUNCTION's parameters.
                          This is potentially dangerous, since using BYVAL in the calling code switches off type-checking for those parameters, so unless you know exactly what you are doing, using BYVAL arbitarily may cause you more problems...

                          In my opinion it would have been better to solve the Error 426 problem rather than just bluntly apply BYVAL to everything in sight.

                          ------------------
                          Lance
                          PowerBASIC Support
                          mailto:[email protected][email protected]</A>
                          Lance
                          mailto:[email protected]

                          Comment

                          Working...
                          X