[sane-devel] Generate C source code from a USBSnoopy log

2003-01-25 Thread Bertrik Sikken
Thomas Soumarmon wrote:

>I have been playing around with my HP5470c scanner for some days without any 
>good results. I tried to handwrite C code corresponding to USBSnoopy logs I 
>got before as the logs are a bit long and tough, it never worked fully. So I 
>decided to replay the log with usb-robot. Logs did not fit with the expected 
>syntax... annoying.
>So I decided to write an awk program that would write for me the C sourcecode 
>that replays the log, and it works.
>Now I'll need to add the code to write the image to a file. Could anybody tell 
>me which format should I expect for the image (RGB pixels from top left ?). 
>
I found that for the HP ScanJet 3300, image data is delivered like this:
one line of red data, one line of green data, one line of blue data.
To make it more complicated, the red, green and blue lines are
out-of-sync vertically, meaning that the scanner delivers it like this:
* red data of line 1, green data of line 2, blue data of line 3
* red data of line 2, green data of line 3, blue data of line 4
* red data of line 3, green data of line 4, blue data of line 5
etcetera
And also it turned out for the hp3300 that the image was mirrored
left-to-right, but this is straightforward to correct.

SANE and the pnm format require the data to be delivered in R,G,B per pixel.

>Is there a library I should use for image saving and processing (ImageMagick 
>?). Thank you for your help.
>
For the hp3300 testtool I used the pnm file format.
A pnm file is very easy to create, just a text header followed
by raw RGB data. I then used gimp to view the result.

Bertrik



[sane-devel] Generate C source code from a USBSnoopy log

2003-01-24 Thread Henning Meier-Geinitz
Hi,

On Fri, Jan 24, 2003 at 01:30:02PM +0100, Thomas Soumarmon wrote:
> I have been playing around with my HP5470c scanner for some days without any 
> good results. I tried to handwrite C code corresponding to USBSnoopy logs I 
> got before as the logs are a bit long and tough, it never worked fully. So I 
> decided to replay the log with usb-robot. Logs did not fit with the expected 
> syntax... annoying.

I think usb-robot is for an older version of snoopy. Tha one wrote
directly to a file instead to that nice window.

> So I decided to write an awk program that would write for me the C sourcecode 
> that replays the log, and it works.
> Now I'll need to add the code to write the image to a file. Could anybody 
> tell 
> me which format should I expect for the image (RGB pixels from top left ?). 

Well ,that's part of the things you should find out :-) In the hope
that the stream isn't compressed somehow you usually get lines of
data. Either RGBRGB... (or BGRBGR...) or RRGB.
That means, pixel-interleaved or line-interleaved.

That was for 8 bit. For 16 or 12 bit it may be more complicated.

> Is there a library I should use for image saving and processing (ImageMagick 
> ?). Thank you for your help.

I would just use pnm for testing. Write the header (normal ascii text)
and then just dump the data. See scanimage.c for an example and man
pnm, man ppm, man pgm.

Bye,
  Henning


[sane-devel] Generate C source code from a USBSnoopy log

2003-01-24 Thread Thomas Soumarmon
Hi everybody,

I have been playing around with my HP5470c scanner for some days without =
any=20
good results. I tried to handwrite C code corresponding to USBSnoopy logs=
 I=20
got before as the logs are a bit long and tough, it never worked fully. S=
o I=20
decided to replay the log with usb-robot. Logs did not fit with the expec=
ted=20
syntax... annoying.
So I decided to write an awk program that would write for me the C source=
code=20
that replays the log, and it works.
Now I'll need to add the code to write the image to a file. Could anybody=
 tell=20
me which format should I expect for the image (RGB pixels from top left ?=
).=20
Is there a library I should use for image saving and processing (ImageMag=
ick=20
?). Thank you for your help.

I suppose that tha tool could be of interest for more people so it is=20
available for download at sourceforge :
http://prdownloads.sourceforge.net/hp5400backend/USBSnoopy2CsourceCode.ta=
r.gz?download

Just a few notes :
* This tool works with libusb. Feell free to port it to the kernel USB li=
b if=20
you know how to do it.
* you need awk and a C compiler to use it (if you don't have them, it is=20
probably of no use for you)

Regs,

Thomas.