Hi folks, thought some of you might be interested in these two
items (feel free to modify/use as uou wish).
I've built a couple of command-line screen-shot tools for use
under Linux (yes I know there are similar projects out in the
wild & now there are two more <g>).
The 1st is called root2jpg, it takes a timed screen-shot in
jpg format. Sources here:
<http://www.topcat.hypermart.net/root2jpg.html>
The 2d is called root2xpm, it takes a timed screen-shot in
pixmap (XPM) format. Sources here:
<http://www.topcat.hypermart.net/root2xpm.html>
Happy holidays to you all.
--
later on,
Mike
http://www.topcat.hypermart.net/index.html
|
|
0
|
|
|
|
Reply
|
mss (26)
|
12/24/2011 11:21:52 AM |
|
mss , dans le message <jd4ckg$std$1@news.albasani.net>, a �crit�:
> The 1st is called root2jpg, it takes a timed screen-shot in
> jpg format. Sources here:
Why did you feel the need to reimplement this? I believe you are aware that
"sleep n && import -window root image.jpg" does the same thing, with import
from the ImageMagick package.
> <http://www.topcat.hypermart.net/root2jpg.html>
# char buf[256]; // buffer for error messages
Why do you use a buffer rather than a pointer? This is uselessly cluttering
the code and copying memory.
Also note that using unnamed integer constants like you do is very bad
design: what happens if you decide to reorder your error messages
alphabetically or thematically? Either put the error message directly where
it is used or use named constants.
# sprintf(buf, "value must be from 1 to 59");
Not that it matters here, but sprintf is often a security issue.
# tmp = malloc(sizeof(char)*3*img->width*img->height);
# pixel = XGetPixel(img,x,y);
# tmp[y*img->width*3+x*3+0] = (pixel>>16); // red
# tmp[y*img->width*3+x*3+1] = ((pixel&0x00ff00)>>8); // green
# tmp[y*img->width*3+x*3+2] = (pixel&0x0000ff); // blue
This is only valid in 24- and 32-bits video mode, and possibly only on
little-endian architectures. To always work, you need to query the visual,
examine the masks if it is TrueColor or query the palette if it is paletted.
# int x = strcmp(argv[1], "-s"); // -s option
# int y = strcmp(argv[3], "-f"); // -f option
The point of options is that they are optional. If the options are mandatory
and in a fixed order at that, just use plain arguments. And if you want to
use options, use standard options parsing functions that allows them to be
optional and in an arbitrary order.
|
|
0
|
|
|
|
Reply
|
george54 (194)
|
12/24/2011 11:38:38 AM
|
|
Nicolas George wrote:
> Why did you feel the need to reimplement this? I believe you are aware that
> "sleep n && import -window root image.jpg" does the same thing, with import
> from the ImageMagick package.
Not using ImageMagick... besides this question is realitive, I wanted
to give it a try that's reason enough.
> Why do you use a buffer rather than a pointer? This is uselessly cluttering
> the code and copying memory.
>
> Also note that using unnamed integer constants like you do is very bad
> design: what happens if you decide to reorder your error messages
> alphabetically or thematically? Either put the error message directly where
> it is used or use named constants.
>
> # sprintf(buf, "value must be from 1 to 59");
>
> Not that it matters here, but sprintf is often a security issue.
>
> # tmp = malloc(sizeof(char)*3*img->width*img->height);
>
> # pixel = XGetPixel(img,x,y);
> # tmp[y*img->width*3+x*3+0] = (pixel>>16); // red
> # tmp[y*img->width*3+x*3+1] = ((pixel&0x00ff00)>>8); // green
> # tmp[y*img->width*3+x*3+2] = (pixel&0x0000ff); // blue
>
> This is only valid in 24- and 32-bits video mode, and possibly only on
> little-endian architectures. To always work, you need to query the visual,
> examine the masks if it is TrueColor or query the palette if it is paletted.
>
> # int x = strcmp(argv[1], "-s"); // -s option
> # int y = strcmp(argv[3], "-f"); // -f option
>
> The point of options is that they are optional. If the options are mandatory
> and in a fixed order at that, just use plain arguments. And if you want to
> use options, use standard options parsing functions that allows them to be
> optional and in an arbitrary order.
Send me patch (no really), I'll learn from it, & we'll all have a better
tool.
--
later on,
Mike
http://www.topcat.hypermart.net/index.html
|
|
0
|
|
|
|
Reply
|
mss (26)
|
12/24/2011 12:07:31 PM
|
|
mss wrote:
> Not using ImageMagick... besides this question is realitive, I wanted
> to give it a try that's reason enough.
Excuse the grammar - I'm wrestling with a 3 year old
granddaughter who wants to play!
--
later on,
Mike
http://www.topcat.hypermart.net/index.html
|
|
0
|
|
|
|
Reply
|
mss (26)
|
12/24/2011 12:21:44 PM
|
|
Nicolas George <nicolas$george@salle-s.org> writes:
>mss , dans le message <jd4ckg$std$1@news.albasani.net>, a �crit�:
>> The 1st is called root2jpg, it takes a timed screen-shot in
>> jpg format. Sources here:
>
>Why did you feel the need to reimplement this? I believe you are aware that
>"sleep n && import -window root image.jpg" does the same thing, with import
>from the ImageMagick package.
And xwd(1)/xpr(1) has been around since day one. In conjunction with convert from
ImageMagick or the netpbm package it can be converted to pretty much any format.
scott
|
|
0
|
|
|
|
Reply
|
scott
|
12/24/2011 3:50:00 PM
|
|
On 2011-12-24, Nicolas George <nicolas$george@salle-s.org> wrote:
>
> # sprintf(buf, "value must be from 1 to 59");
>
> Not that it matters here, but sprintf is often a security issue.
Condemning good uses of a function just because it *could* be used
improperly is really stupid.
If you know the size of the buffer and you know the size of the input, it's
perfectly reasonable to use sprintf, strcpy, etc. No need to needlessly
complicate things.
--
John Tsiombikas
http://nuclear.mutantstargoat.com/
|
|
0
|
|
|
|
Reply
|
nuclear6 (33)
|
12/27/2011 8:56:22 AM
|
|
John Tsiombikas , dans le message
<slrnjfj21m.bto.nuclear@goat.mutantstargoat.com>, a �crit�:
>> Not that it matters here, but sprintf is often a security issue.
> Condemning good uses of a function just because it *could* be used
> improperly is really stupid.
You are right. And I would like you to acknowledge that I did not do it,
since I explicitly wrote: not that it matters here.
But there was enough clumsy programming that I felt it was necessary to
mention it for reference.
|
|
0
|
|
|
|
Reply
|
george54 (194)
|
12/27/2011 10:13:07 AM
|
|
Nicolas George wrote:
> But there was enough clumsy programming that I felt it was necessary to
> mention it for reference.
Nicolas, its a silly little app if you'd bother to consider it
more. Clumsy here is really nothing more than how you feel.
It was built on a whim, & I choose to share the sources thinking
others might build on it.
I suggest you get some fresh air & enjoy life, its fun when
allow it to be so.
--
later on,
Mike
http://www.topcat.hypermart.net/index.html
|
|
0
|
|
|
|
Reply
|
mss (26)
|
12/27/2011 11:09:32 AM
|
|
mss , dans le message <jdc91c$2eb$1@news.albasani.net>, a �crit�:
> Nicolas, its a silly little app if you'd bother to consider it
> more. Clumsy here is really nothing more than how you feel.
>
> It was built on a whim, & I choose to share the sources thinking
> others might build on it.
That exactly the problem: it starts as a silly little app, but it may grow
into something else, especially since you made the code public: yourself or
other may copy it or build on it to integrate into a bigger project.
You should have taken my first message as a chance to learn and enhance your
codding style so that you may become a skilled hacker and not one of those
innumerable coding monkeys who produce more bugs and security holes than
features.
Now, if you do not want my advice, good for you, I also have more important
things to do.
|
|
0
|
|
|
|
Reply
|
george54 (194)
|
12/27/2011 11:42:34 AM
|
|
Nicolas George wrote:
> Now, if you do not want my advice, good for you, I also have more important
> things to do.
Nick, lets reboot this conversation...
Me? I enjoy learning & am fairly new to C still yet. So far, you've
only told me what you *would not* have done, instead, show & explain
to me what you *would* have done.
--
later on,
Mike
http://www.topcat.hypermart.net/index.html
|
|
0
|
|
|
|
Reply
|
mss (26)
|
12/27/2011 12:10:22 PM
|
|
mss , dans le message <jdccjd$8oc$1@news.albasani.net>, a �crit�:
> Me? I enjoy learning & am fairly new to C still yet.
That's the spirit!
> So far, you've
> only told me what you *would not* have done, instead, show & explain
> to me what you *would* have done.
I do not have time to actually write the code and test it. I believe my
first message gave plenty of pointers about the part of your code that could
be enhanced, and how they could be enhanced. Looking into it deeper by
yourself is probably a better way to discover things than looking at someone
else's code.
|
|
0
|
|
|
|
Reply
|
george54 (194)
|
12/27/2011 12:23:06 PM
|
|
Nicolas George wrote:
> I do not have time to actually write the code and test it. I believe my
> first message gave plenty of pointers about the part of your code that could
> be enhanced, and how they could be enhanced. Looking into it deeper by
> yourself is probably a better way to discover things than looking at someone
> else's code.
Very disappointing, you expect the privilege of criticizing without
shouldering the responsibility of explanation (in code)?
<grumble>
never-mind, running late for work.
--
later on,
Mike
http://www.topcat.hypermart.net/index.html
|
|
0
|
|
|
|
Reply
|
mss (26)
|
12/27/2011 1:26:31 PM
|
|
mss , dans le message <jdch27$j1o$1@news.albasani.net>, a �crit�:
> Very disappointing, you expect the privilege of criticizing without
> shouldering the responsibility of explanation (in code)?
I believe my criticism was constructive enough. If you do not find it so,
good for you, just ignore it.
|
|
0
|
|
|
|
Reply
|
george54 (194)
|
12/27/2011 1:39:48 PM
|
|
On 2011-12-27, Nicolas George <nicolas$george@salle-s.org> wrote:
> John Tsiombikas , dans le message
><slrnjfj21m.bto.nuclear@goat.mutantstargoat.com>, a ?crit�:
>>> Not that it matters here, but sprintf is often a security issue.
>> Condemning good uses of a function just because it *could* be used
>> improperly is really stupid.
>
> You are right. And I would like you to acknowledge that I did not do it,
> since I explicitly wrote: not that it matters here.
>
> But there was enough clumsy programming that I felt it was necessary to
> mention it for reference.
Alright then.
--
John Tsiombikas
http://nuclear.mutantstargoat.com/
|
|
0
|
|
|
|
Reply
|
nuclear6 (33)
|
12/28/2011 7:53:08 PM
|
|
In article <slrnjfj21m.bto.nuclear@goat.mutantstargoat.com>,
John Tsiombikas <nuclear@member.fsf.org> wrote:
>On 2011-12-24, Nicolas George <nicolas$george@salle-s.org> wrote:
>>
>> # sprintf(buf, "value must be from 1 to 59");
>>
>> Not that it matters here, but sprintf is often a security issue.
>
>Condemning good uses of a function just because it *could* be used
>improperly is really stupid.
>
>If you know the size of the buffer and you know the size of the input, it's
>perfectly reasonable to use sprintf, strcpy, etc. No need to needlessly
>complicate things.
Agreed. Over in comp.lang.c, we call these types of posters (e.g., the one
you are responding to) "human compilers". And the point is that, like a
regular compiler, they can just spit out meaningless warnings that say,
essentially, "this could be a problem".
Well, the point, of course, is that *anything* *could* be a problem. But we
don't expect mechanized warnings generators to be aware of this subtlety.
--
First of all, I do not appreciate your playing stupid here at all.
- Thomas 'PointedEars' Lahn -
|
|
0
|
|
|
|
Reply
|
gazelle3 (1598)
|
12/29/2011 10:55:50 AM
|
|
In article <4ef9af2a$0$9471$426a74cc@news.free.fr>,
Nicolas George <nicolas$george@salle-s.org> wrote:
>mss , dans le message <jdc91c$2eb$1@news.albasani.net>, a �crit�:
>> Nicolas, its a silly little app if you'd bother to consider it
>> more. Clumsy here is really nothing more than how you feel.
>>
>> It was built on a whim, & I choose to share the sources thinking
>> others might build on it.
>
>That exactly the problem: it starts as a silly little app, but it may grow
>into something else, especially since you made the code public: yourself or
>other may copy it or build on it to integrate into a bigger project.
>
>You should have taken my first message as a chance to learn and enhance your
>codding style so that you may become a skilled hacker and not one of those
>innumerable coding monkeys who produce more bugs and security holes than
>features.
>
>Now, if you do not want my advice, good for you, I also have more important
>things to do.
You really do need to get a life. You might want to look into it.
As Mike instructed you, it (having a life) really can be fun, if you give it
a chance.
--
First of all, I do not appreciate your playing stupid here at all.
- Thomas 'PointedEars' Lahn -
|
|
0
|
|
|
|
Reply
|
gazelle3 (1598)
|
12/29/2011 10:58:15 AM
|
|
In article <4ef9b8aa$0$658$426a34cc@news.free.fr>,
Nicolas George <nicolas$george@salle-s.org> wrote:
>mss , dans le message <jdccjd$8oc$1@news.albasani.net>, a �crit�:
>> Me? I enjoy learning & am fairly new to C still yet.
>
>That's the spirit!
>
>> So far, you've
>> only told me what you *would not* have done, instead, show & explain
>> to me what you *would* have done.
>
>I do not have time to actually write the code and test it. I believe my
>first message gave plenty of pointers about the part of your code that could
>be enhanced, and how they could be enhanced. Looking into it deeper by
>yourself is probably a better way to discover things than looking at someone
>else's code.
Translation: I'm too lazy to actually help you (by, as suggested, supplying
patches). I'd rather just sit back and bitch (and make myself feel like a
grand instructor - dispensing knowledge from on high).
--
Windows 95 n. (Win-doze): A 32 bit extension to a 16 bit user interface for
an 8 bit operating system based on a 4 bit architecture from a 2 bit company
that can't stand 1 bit of competition.
Modern day upgrade --> Windows XP Professional x64: Windows is now a 64 bit
tweak of a 32 bit extension to a 16 bit user interface for an 8 bit
operating system based on a 4 bit architecture from a 2 bit company that
can't stand 1 bit of competition.
|
|
0
|
|
|
|
Reply
|
gazelle3 (1598)
|
12/29/2011 10:59:55 AM
|
|
In article <jdch27$j1o$1@news.albasani.net>, mss <mss@dev.null> wrote:
>Nicolas George wrote:
>
>> I do not have time to actually write the code and test it. I believe my
>> first message gave plenty of pointers about the part of your code that could
>> be enhanced, and how they could be enhanced. Looking into it deeper by
>> yourself is probably a better way to discover things than looking at someone
>> else's code.
>
>Very disappointing, you expect the privilege of criticizing without
>shouldering the responsibility of explanation (in code)?
Exactly. You've got his number.
--
They say compassion is a virtue, but I don't have the time!
- David Byrne -
|
|
0
|
|
|
|
Reply
|
gazelle3 (1598)
|
12/29/2011 11:00:28 AM
|
|
Kenny McCormack, dans le message <jdhh47$k9d$5@news.xmission.com>, a
�crit�:
> You really do need to get a life. You might want to look into it.
>
> As Mike instructed you, it (having a life) really can be fun, if you give it
> a chance.
You know nothing about me, so please refrain from such offensive comments. I
gave advice and constructive critics to someone who obviously has little
programming experience. If I had known that the OP would wipe himself with
it and call all anonymous cowards of this newsgroup to band together, I
would have spent my time for people who actually care.
|
|
0
|
|
|
|
Reply
|
george54 (194)
|
12/29/2011 11:05:09 AM
|
|
In article <4efc4965$0$16267$426a74cc@news.free.fr>,
Nicolas George <nicolas$george@salle-s.org> wrote:
>Kenny McCormack, dans le message <jdhh47$k9d$5@news.xmission.com>, a
> �crit�:
>> You really do need to get a life. You might want to look into it.
>>
>> As Mike instructed you, it (having a life) really can be fun, if you give it
>> a chance.
>
>You know nothing about me, so please refrain from such offensive comments. I
>gave advice and constructive critics to someone who obviously has little
>programming experience. Blah, blah, blah...
Allow me to return the favor, with a little lesson in etiquette. It is
generally a good idea to find out first, via polite inquiry, whether someone
is interested in "help", before rendering such. In polite society, we go out
of our way to find out whether help will be welcomed (and, thus, have some
chance of being actually useful to the intended recipient) before
broadcasting forth with said "help". That this style is rarely adhered to
online (particularly true in an old-style medium like Usenet) is a pity. It
reflects on the "Aspergers-ness" of the participants.
Also see my comments in another post, re: "human compilers" (such as
yourself).
In short, just in case the above style is too subtle for you, I find it
really repulsive when someone posts something they've done, in the spirit of
"Hey! I had fun with this; you might, too. Isn't it cool?" and what they
get back is crap such as that which we've seen from you.
--
"We should always be disposed to believe that which appears to us to be
white is really black, if the hierarchy of the church so decides."
- Saint Ignatius Loyola (1491-1556) Founder of the Jesuit Order -
|
|
0
|
|
|
|
Reply
|
gazelle3 (1598)
|
12/29/2011 11:37:27 AM
|
|
Kenny McCormack, dans le message <jdhh7b$k9d$6@news.xmission.com>, a
�crit�:
<snip>
Your messages, and especially their lack of actual relevance with regard to
what I actually wrote, convinced me you are nothing but a troll. I will
henceforth ignore whatever you may write, until maybe you start posting
something of actual worth.
Good day.
|
|
0
|
|
|
|
Reply
|
george54 (194)
|
12/29/2011 12:43:50 PM
|
|
In article <4efc6086$0$16204$426a74cc@news.free.fr>,
Nicolas George <nicolas$george@salle-s.org> wrote:
>Kenny McCormack, dans le message <jdhh7b$k9d$6@news.xmission.com>, a
> �crit�:
><snip>
>
>Your messages, and especially their lack of actual relevance with regard to
>what I actually wrote, convinced me you are nothing but a troll. I will
>henceforth ignore whatever you may write, until maybe you start posting
>something of actual worth.
You were not expected to get it. One of the classic Aspergers symptoms is a
complete inability to perceive how others perceive yourself. My posts were
for the benefit of others.
>Good day.
Nice Dickensian reference there. I like it!
--
Some of the more common characteristics of Asperger syndrome include:
* Inability to think in abstract ways (eg: puns, jokes, sarcasm, etc)
* Difficulties in empathising with others
* Problems with understanding another person's point of view
* Hampered conversational ability
* Problems with controlling feelings such as anger, depression
and anxiety
* Adherence to routines and schedules, and stress if expected routine
is disrupted
* Inability to manage appropriate social conduct
* Delayed understanding of sexual codes of conduct
* A narrow field of interests. For example a person with Asperger
syndrome may focus on learning all there is to know about
baseball statistics, politics or television shows.
* Anger and aggression when things do not happen as they want
* Sensitivity to criticism
* Eccentricity
* Behaviour varies from mildly unusual to quite aggressive
and difficult
|
|
0
|
|
|
|
Reply
|
gazelle3 (1598)
|
12/29/2011 2:07:51 PM
|
|
Nicolas George wrote:
> Your messages, and especially their lack of actual relevance with regard to
> what I actually wrote, convinced me you are nothing but a troll. I will
> henceforth ignore whatever you may write, until maybe you start posting
> something of actual worth.
>
> Good day.
Nah, Kenny's a good guy (he's helped me allot towards learning more
[g|m]awk & regex). Chuckle, he'll also challenge flippant behavior
in a New York minute. When you think about it, just as you put in
your umm... two cents, so did he.
--
later on,
Mike
http://www.topcat.hypermart.net/index.html
|
|
0
|
|
|
|
Reply
|
mss (26)
|
12/29/2011 4:38:31 PM
|
|
Kenny McCormack wrote:
>>Very disappointing, you expect the privilege of criticizing without
>>shouldering the responsibility of explanation (in code)?
>
> Exactly. You've got his number.
Must admit, it did catch me off guard...
The ol' 'it sucks!' I could expect, but a 'clumsy' with no
demonstration that conveyed his thinking, I dunno, I guess
I'd have handled it differently if it were me. No biggie.
So I'm new to usenet - <shrugs>
--
later on,
Mike
http://www.topcat.hypermart.net/index.html
|
|
0
|
|
|
|
Reply
|
mss (26)
|
12/29/2011 4:46:44 PM
|
|
mss , dans le message <jdi527$8ic$1@news.albasani.net>, a �crit�:
> When you think about it, just as you put in
> your umm... two cents, so did he.
My two cents were technical advice to you: about options, pointers, possible
security issues that you may not have been aware of, limitations of your
program, etc.
His two cents were ad-hominem attacks.
|
|
0
|
|
|
|
Reply
|
george54 (194)
|
12/29/2011 5:07:49 PM
|
|
|
24 Replies
40 Views
(page loaded in 2.475 seconds)
|