User Profile

Collapse

Profile Sidebar

Collapse
macklin01
macklin01
Last Activity: Feb 8 '10, 06:47 AM
Joined: Aug 21 '05
Location: Houston, TX
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Ah, I see. Good point.

    Something like this, then:

    // loop over all pixels
    RGBApixel temp = *img(i1,j1);
    *img(i1,j1) = *img(i2,j2);
    *img(i2,j2) = temp;

    // or like this
    // loop over all pixels

    BYTE temp = img(i1,j1)->Red;
    img(i1,j1)->Red = img(i2,j2)->Red;
    img(i2,j2)->Red = temp;
    // repeat for green, blue, alpha

    The latter is more...
    See more | Go to post

    Leave a comment:


  • Hi, Bryant.

    In the code above, you are overwriting the pixels of img as you go, which means that you will lose half the image before you finish.

    Instead, make a second, blank image, say:

    BMP blank;
    blank.SetSize( img.TellWidth() , img.TellHeight( ) );

    Then, use your same code, only with "img" as the source and "blank" as the destination.

    As for...
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to how to read a doc & pdf file in C++
    in C
    PDF files have a very specific format, which is documented by Adobe in rather lengthy specs. To read an arbitrary PDF file, you'll need to implement a lot of features of the standard.

    DOC files are worse: they are (to some extent) a binary dump of MS Word's memory, +/- some formatting. MS does not document the format in any kind of public way, and even their "Open"XML format standard has things like "do this feature...
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to C++ and Intel fortran coupling
    in C
    How did things ever turn out for you on this? Steven McDougall told me you found a solution. Thanks -- Paul...
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to what header file is used for sleep( )
    in C
    Have you tried unistd.h? -- Paul
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to Plot Data Visualiation for 2D arrays
    in C
    No problem, dr. s.

    While most of the code uses C, EasyBMP is implemented as a few C++ classes, particularly the BMP class. (The object-oriented nature of C++ makes it much easier to implement the read/write functions, etc.) Thanks -- Paul...
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to c editor for cygwin
    in C
    You might also consider using nedit directly from the cygwin shell. (If you also run x.) -- Paul
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to need some help for constructing a .bmp file
    in C
    Once you write the file headers of the image, you could overwrite the pixel data with the text. On a standard, 24 bit per pixel image, red, green, and blue are 1 byte each, i.e., 3 characters.

    If you decide to use C++ instead of C, you can use my open source / cross-platform EasyBMP C++ bitmap library. Using that, it's very easy.

    Code:
    #include "EasyBMP.h" 
    
    // ... 
    
    // assume
    ...
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to Plot Data Visualiation for 2D arrays
    in C
    Do'h!

    Still wasn't fast enough. Darn those stringent limits! :) Here it is for real. ;) -- Paul...
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to Plot Data Visualiation for 2D arrays
    in C
    I didn't get the image uploaded in time. Here's a (highly degraded) version, to fit in the upload size limits. -- Paul
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to Plot Data Visualiation for 2D arrays
    in C
    I wrote some open source code to visualize 2D arrays. Have a look at the EasyBMP project, and take a look at the DataPlotter program.

    IIRC, I need to update that program, so let me know if you encounter problems. But a pre-compiled version is included.

    Also, here's a very simple way to visualize a 2D array in grayscale:
    Code:
    #include "EasyBMP.h"
    
    // ...
    
    // suppose you
    ...
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to Plotting Algaebric Curves
    in C
    Hello, and thank you for your post.

    Are you looking for feedback? I'm not entirely sure what you'd like. But it looks like a fun program. (And I scanned it for viruses, folks, so no problems there. ;)) -- Paul
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to Reuse of File pointer
    in C
    Good question.

    On the one hand, the istream pointers probably wouldn't take _that_ much memory, but on the other hand, I agree that it's unsatisfactory that you can't take your approach. (Which I feel is more elegant.)

    Are you sure this isn't a compiler bug? Have you tried another compiler?

    Also, I'd recommend trying a smaller code snippet until you can track something down that works. e.g.,
    ...
    See more | Go to post

    Leave a comment:


  • I don't use the TurboC++ compiler, but you could just open the C++ files in any text editor and print them from there. (I take it that you mean to print the source code.) -- Paul
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to How to change directory on File Search
    in C
    Hmm,

    In part, I think you need to interact with the operating system to get that kind of information. In windows, that means win32 calls. TurboC++ may have specific functions to help with that, but because it's not standard C++, I can't be of much help to you on that end. However, I'd recommend digging around MS's site for win32 API calls to get directory listings.

    Good luck -- Paul
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to how to put classes into a 2d array
    in C
    Best advice I've seen all day! (And way better than mine!) :) -- Paul...
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to recursions in functions
    in C
    I'm not sure what you meant by this.

    At any rate, how did it turn out? -- Paul...
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to how to put classes into a 2d array
    in C
    Well, if you look at the BMP object in EasyBMP.cpp in my EasyBMP C++ bitmap library, you'll find that the pixels are a 2-D array of ebmpBYTE structs:

    Code:
    BMP
    {
     private:
      ebmpBYTE** Pixels;
      // ... 
    };
    I'd recommend studying that example. While the ebmpBYTE's are structs and not objects, the idea is exactly the same. Incidentally, it's also the same as doing a 2-D array...
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to Graphics With Gcc
    in C
    Not a problem. :)



    Well, there's not much to tell, as it was designed to be cross platform. Roughly speaking:

    1) Copy the EasyBMP*.h and EasyBMP.cpp to the project directory.

    2) Include EasyBMP.h in your project:
    Code:
    /* ... */
    #include "EasyBMP.h"
    /* ... */
    3) Compile EasyBMP along with your project and link:
    Code:
    g+[b][/b]+ -o
    ...
    See more | Go to post

    Leave a comment:


  • macklin01
    replied to DirectX 9 - problem with sprites
    in C
    I don't use DirectX, but I think the idea can be summarized as follows:

    1) Determine when a mouse click event occurs.
    2) Get the screen coordinates of the mouse cursor position (in pixels) when that happens.
    3) Translate the pixel coordinates into the coordinates of your game. For instance, if

    screen is 640 x 480
    game coordinates are 0 <= x <= 4 , 0 <= y <= 3,
    mouse coordinates...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...