|
You don't need a library. You don't need to worry about storing it in memory. If all your image is is a sequence of drawn black lines, just produce trivial PostScript output. In your code, start off the program by outputting "%!PS" to some file so you're valid PostScript, then "72 1400 div dup scale" so you're in 1400 DPI instead of 72 DPI. For every line from (x1,y1)->(x2,y2), output "newpath x1 y1 moveto x2 y2 lineto stroke". At the end, output "showpage". That's it, you're done, you've produced a PostScript file that contains your image. Save it with a .ps extension and give it to the printer. Edit: 1400, not 1440 DPI. ShoulderDaemon fucked around with this message at 20:18 on Apr 28, 2008 |
# ? Apr 28, 2008 20:13 |
|
|
# ? May 18, 2024 02:59 |
|
The_Carp posted:make input1.txt Just use make -f filename
|
# ? Apr 28, 2008 20:21 |
|
I'm having some trouble with a doubly linked list in C++. For some reason, I keep getting errors like:code:
Here is the relevant code from my LinkedSet.h file: code:
code:
Do I need to include "template <typename T>" and all that stuff for the subclass node, since the class linkedset is a template class? Viper2026 fucked around with this message at 23:35 on Apr 28, 2008 |
# ? Apr 28, 2008 23:19 |
|
I could be wrong, but I don't think your remove function should be declared/defined as const.
|
# ? Apr 28, 2008 23:43 |
|
SintaxError posted:I could be wrong, but I don't think your remove function should be declared/defined as const. Yes, although the node_count = node_count - 1; shouldn't compile like this anyway. But yeah, remove shouldn't be const.
|
# ? Apr 28, 2008 23:53 |
|
Ah thanks very much, it got rid of the assignment errors Remove is also defined as a virtual in my SetADT.h so I also had to remove virtual from my linkedset.h, I hope that doesn't screw anything up. And am I correct in assuming the conversion from double to NULL warning aren't much to worry about?
|
# ? Apr 28, 2008 23:59 |
|
It is an issue. I'm assuming the "converting NULL to double" error occurs at return NULL; in your code. That's bad because NULL isn't a valid value for non-pointer, non-integral types. It's performing an implicit conversion from a pointer (integer) type to the type of the elements in your list. Think about what would happen if there is no such conversion...
|
# ? Apr 29, 2008 00:37 |
|
Avenging Dentist posted:It is an issue. I'm assuming the "converting NULL to double" error occurs at return NULL; in your code. That's bad because NULL isn't a valid value for non-pointer, non-integral types. It's performing an implicit conversion from a pointer (integer) type to the type of the elements in your list. Think about what would happen if there is no such conversion... If you can change the signature of the function, I would return a bool instead of a T. There is no generic "bad" value for all types in C++. However, since your function already takes the element to remove, the caller already knows what element will be removed, and returning it is redundant. I would return true if the element was found and removed, and false otherwise.
|
# ? Apr 29, 2008 01:09 |
|
That's true. Honestly, I just skimmed over the code.
|
# ? Apr 29, 2008 01:58 |
|
ShoulderDaemon posted:You don't need a library. You don't need to worry about storing it in memory. If all your image is is a sequence of drawn black lines, just produce trivial PostScript output. Ok, I made the PS file of the image. This is the situation as it stands: a) small images are made perfectly, the numbers work out and everything and the image is perfect b) the large image does not display correctly at all, it's cut short on the top and bottom, presumably because I'm doing something on the order of "newpath 10 10 moveto 33600 336000 lineto stroke" and the numbers are just too big to display correctly in a PS viewer c) the file is not readable in any Adobe reader, it says it is corrupted and unreadable, but various PS readers like GSView etc, can read it fine. If I hand this PS file to the printer, and they can't read it, I'm out of luck, do I need some kind of special header for Adobe to read it? Thanks.
|
# ? Apr 29, 2008 04:33 |
|
ruden posted:Ok, I made the PS file of the image. This is the situation as it stands: Look up line-drawing algorithms. You could initialize a 12GB raw image file with zeros, then draw lines by doing file seeks and writes. It wouldn't be pretty, and it might take a very long time, but with good filesystem caching it might be manageable.
|
# ? Apr 29, 2008 04:53 |
|
Filling in a 12GB range with unpredictable writes of single bytes? When did he say this project had to be finished by? (And don't forget to throw in a targa header before you start writing pixels.)
|
# ? Apr 29, 2008 04:56 |
|
Scaevolus posted:Look up line-drawing algorithms. You could initialize a 12GB raw image file with zeros, then draw lines by doing file seeks and writes. It wouldn't be pretty, and it might take a very long time, but with good filesystem caching it might be manageable. That's the worst idea I've ever heard. The man is doing VECTOR GRAPHICS.
|
# ? Apr 29, 2008 04:58 |
|
Assuming each single byte write takes 1/10,000 of a second, and other processing time is negligible, it would only take a week, if 50% of the pixels are filled. This is the sacrifice one must make for 1400 DPI.
|
# ? Apr 29, 2008 05:14 |
|
Is there any good C IDEs for Linux? All I ever hear about is Visual Studio. At the moment I've been using Emacs for it but I was wondering if there was anything else
|
# ? Apr 29, 2008 05:33 |
|
That sounds like a lot more work/processing power than I have time for. This PS file is all made and seems to be coded perfectly. I just need to know how to make it display such a large file. Manipulating 0s and 1s for a week sounds like an awful waste of time.
|
# ? Apr 29, 2008 05:46 |
|
ruden posted:Ok, I made the PS file of the image. Adobe is choking because your document isn't DSC compliant and Adobe doesn't actually produce raw PostScript interpreters. GhostScript isn't inferring the correct bounding box because GhostScript is a really amazingly bad PostScript interpreter. Real printers typically know what size of paper they are using instead of having to infer it from the document being printed, and they also tend to not care about the metadata that lets them do fancy tricks like print pages out of order, but software does. The solution is to add the DSC headers. I think making your output look something like this should be enough: code:
|
# ? Apr 29, 2008 05:57 |
|
Is that the correct dimensions for the 336020x33620 banner? I'm not too familiar with the PS headers, so I basically copied and pasted it into my Perl file. If I need to change something I would appreciate it, I don't want to mess something up from having wrong dimensions.
|
# ? Apr 29, 2008 06:07 |
|
ruden posted:Is that the correct dimensions for the 336020x33620 banner? I'm not too familiar with the PS headers, so I basically copied and pasted it into my Perl file. If I need to change something I would appreciate it, I don't want to mess something up from having wrong dimensions. PostScript uses 72DPI in calculating dimensions, and doesn't really have a concept of a pixel - You specified 20 ft by 2 ft at one point, so I just did 72 * 12 * 2 by 72 * 12 * 20. If you want those exact "pixel" counts at 1400 DPI, you'll want 72 * 3620 / 1400 and 72 * 336020 / 1400, which aren't round numbers (and BoundingBox is constrained to integer values). I'd probably round up, and go with 1730 and 17282. Whoever setup the printer should be able to tell you exactly what bounding box is most appropriate.
|
# ? Apr 29, 2008 06:17 |
|
Great, thanks a lot for the help. The file is looking like it's theoretically perfect now. I'll have to talk to the printers and see what they need changed to make it print fine.
|
# ? Apr 29, 2008 06:21 |
|
Donald Duck posted:Is there any good C IDEs for Linux? All I ever hear about is Visual Studio. At the moment I've been using Emacs for it but I was wondering if there was anything else Check out this thread in SH/SC, it should answer your question.
|
# ? Apr 29, 2008 14:54 |
|
C question: I was doing all the simple exercises in the K&R book to catch back up on it and I can't seem to fix this problem. I have a feeling its something stupid I've overlooked thats causing this: code:
The program is suppose to take an input, then print out how often each char occured, as a histogram. This worked fine when I just had the line begin with the int value of a char, but when I convert them to chars, the program crashes with a segmentation fault Output is: 0 (null) Segmentation fault. So it is printing the first char out correctly. Donald Duck fucked around with this message at 04:25 on Apr 30, 2008 |
# ? Apr 30, 2008 04:20 |
|
%s expects a char*, not just a char. (Next time, please try to give more information about the crash, at least the line number.)
|
# ? Apr 30, 2008 04:25 |
|
HB posted:%s expects a char*, not just a char. Segmentation faults don't give line numbers... And I was just editing the result in as you printed that, sorry. Thanks, knew it was something like that.
|
# ? Apr 30, 2008 04:26 |
|
For some reason, the cout statements in this portion of my code are not printing anything:code:
EDIT: for some reason using " : " instead of just ":" makes it work... Viper2026 fucked around with this message at 04:35 on Apr 30, 2008 |
# ? Apr 30, 2008 04:30 |
|
Viper2026 posted:For some reason, the cout statements in this portion of my code are not printing anything: Depending on the platform and the stream settings, cout won't flush (print its buffer) until it encounters whitespace. Now changing that or manually flushing it, that I don't remember
|
# ? Apr 30, 2008 04:44 |
|
Donald Duck posted:Segmentation faults don't give line numbers... And I was just editing the result in as you printed that, sorry. If you're using gcc, you can use the -g switch which includes debugging info. If you run the program in gdb, or load a core dump from a debug build in gdb, it'll tell you the line numbers, and it'll even print snippets of the code if it can read the file from the path you compiled it from. I believe MSVC has a similar feature you can use if you compile a debug build and run the application through the IDE.
|
# ? Apr 30, 2008 04:48 |
|
csammis posted:Depending on the platform and the stream settings, cout won't flush (print its buffer) until it encounters whitespace. Now changing that or manually flushing it, that I don't remember If it's an option, replace cout with cerr while debugging (STDERR is unbuffered). Otherwise, look up setbuf(3).
|
# ? Apr 30, 2008 08:41 |
|
Milde posted:If you're using gcc, you can use the -g switch which includes debugging info. If you run the program in gdb, or load a core dump from a debug build in gdb, it'll tell you the line numbers, and it'll even print snippets of the code if it can read the file from the path you compiled it from. code:
|
# ? Apr 30, 2008 11:20 |
|
KaeseEs posted:If it's an option, replace cout with cerr while debugging (STDERR is unbuffered). Otherwise, look up setbuf(3). Sending std::flush or std::endl (flush with newline) to an output stream will also flush its buffer.
|
# ? Apr 30, 2008 17:36 |
|
I'm working on a final project in a C++ class. I'm coding a simulator that outputs the status each timestep (basically a text grid with different characters representing different states). I want to make the program pause half a second between each iteration so that you can see its progress. The lab document says to use the method below, but all it is is a for (int i = 0; i < 1000000000; i++) {} loop that spins CPU cycles incrementing a number. This is obviously less than ideal.code:
|
# ? Apr 30, 2008 21:27 |
|
That's definitely better than "i < 10000000" because it's checking against an actual time instead of just an arbitrary counter, so it works the same no matter how fast your processor's running. The counter method is completely broken; this is just unoptimal. What you want is "sleep" (I think it might be _sleep in Visual C++, nut that shouldn't matter to you). Problem is it only takes whole seconds, so the lowest you can do is "sleep(1);" to sleep for 1 second. If that's ok, this is the easiest. If that's not good enough, you can use "nanosleep" (which I think is Unix-only), which takes a duration measured in nanoseconds but it's a bit more complicated because you need to fill in a structure instead of just passing an int. Google should be able to tell you how to use it.
|
# ? Apr 30, 2008 21:35 |
|
There's also usleep, which takes microseconds. All of these should be in unistd.h
|
# ? Apr 30, 2008 21:46 |
|
Avenging Dentist posted:There's also usleep, which takes microseconds. All of these should be in unistd.h usleep isn't available everywhere, though - nanosleep and sleep are the most portable. Probably doesn't matter in this case, but it's a good idea to get in the habit of using nanosleep.
|
# ? Apr 30, 2008 22:10 |
|
If you're working in windows, you can use Sleep(milliseconds); which is part of the Windows API.
|
# ? Apr 30, 2008 22:36 |
|
Milde posted:If you're using gcc, you can use the -g switch which includes debugging info. If you run the program in gdb, or load a core dump from a debug build in gdb, it'll tell you the line numbers, and it'll even print snippets of the code if it can read the file from the path you compiled it from. if you don't want to take the time to learn how to use gdb, running the program in valgrind (with debugging info) will get you very fast results.
|
# ? May 1, 2008 05:39 |
|
I'm having trouble with a 3 way fork and pipes application. Program 1 has to fork 2 programs, then pipe things through them like so: 1 -> 2 -> 3 -> 1 That way 1 gets the output of 3, and writes into 2. 2 Will write to 3. With my code: http://pastebin.org/33187 I'm having problems aroung line 58, where the 2nd program runs and complains about a bad file descriptor. I can't figure out what I've done wrong, as far as i can see i have done everything right.
|
# ? May 1, 2008 07:31 |
|
I hope someone can tell me what I'm doing wrong, because apparently codepad can't. Here's what's supposed to happen, and what codepad says does happen. code:
code:
|
# ? May 1, 2008 11:29 |
|
elevatordeadline posted:
If it makes you feel any better: code:
code:
code:
vanjalolz fucked around with this message at 12:42 on May 1, 2008 |
# ? May 1, 2008 12:22 |
|
|
# ? May 18, 2024 02:59 |
|
It sayscode:
|
# ? May 1, 2008 12:49 |