[sane-devel] SANE_Handle question

2004-09-19 Thread abel deuring
Paul wrote:
 Hi,
 
 I'm trying to implement using SANE within Scribus and I'm hitting a
 small snag. While the majority of the API is really simple to use, I'm
 having a problem with what SANE_Handle is.

Its great to hear that Scribus will support Sane.

 
 The sane.h header has it defined as 
 
 typedef void *SANE_Handle;
 
 There are plenty of functions which require SANE_Handle, but nothing
 which actually sets it!

Well, there is a function which sets a SANE_Handle variable:

SANE_Status sane_open (SANE_String_Const name, SANE_Handle * h);

But it's easy to miss (or forget) this function while reading the docs 
-- that could have had easily happened for me too ;)

 According to the sane website, SANE does not require that a value of
 this type be a legal pointer value and an application shouldn't attempt
 to interpret the value of SANE_Handle.

I think all currently existing backends interpret SANE_Handle as a 
pointer, but this is not required. A frontend should interpret 
SANE_Handle to be simply an identifier; any assumption that it might be 
possible to access some backend-internal stuff may fail.

 How should I set the handle? For instance, when I obtain the device
 list, I have two show for my USB webcam and one for my scanner. I have
 to be able to set the handle to the scanner. Is it enough to set the
 handle to the device name or should it be set to the physical /dev/sg0
 value (which is not a good idea!)

call sane_get_devices, and use the field SANE_Device.name from the 
elements of device_list as the first parameter in the of call sane_open. 
  Using something like '/dev/sg0' will not work, because Sane does not 
know in this case, which backend should be used; 'mustek:/dev/sg0' might 
work. But I am not sure, if this is reasonable for a graphical 
frontend, where users are not supposed to have read the Sane 
documentation ;) The assignment of device names to real devices can 
offer some suprises. For example, /dev/sg0 means for Linux usually the 
device with the lowest SCSI ID on the first bus of the first adapter. 
But if this device was not powered when the SCSI adapter driver was 
loaded, it can later be made known to the SCSI system by a command like 
'echo scsi add-single-device 0 0 4 0  /proc/scsi/scsi' , and if the 
system has already found three other SCSI devices, the new device will 
be assigned to the device file /dev/sg3.

Abel



[sane-devel] SANE_Handle question

2004-09-19 Thread Paul
--=-QXjUhHAZchXguKpunTzh
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Hi,

  I'm trying to implement using SANE within Scribus and I'm hitting a
  small snag. While the majority of the API is really simple to use, I'm
  having a problem with what SANE_Handle is.
=20
 Its great to hear that Scribus will support Sane.

Still lots to do and a decision as to how much the support will be. Do I
have it so that the scanner scans the image and then let GIMP deal with
the rest or have a very basic area select mechanism? I'm happier to send
things to GIMP, but then I'm lazy ;-p

  There are plenty of functions which require SANE_Handle, but nothing
  which actually sets it!
=20
 Well, there is a function which sets a SANE_Handle variable:
=20
 SANE_Status sane_open (SANE_String_Const name, SANE_Handle * h);
=20
 But it's easy to miss (or forget) this function while reading the docs=20
 -- that could have had easily happened for me too ;)

Actually, I didn't miss it, just it didn't register with me for some
reason. I'm guessing that I spend way too much time doing C++ and C#
now.

  How should I set the handle? For instance, when I obtain the device
  list, I have two show for my USB webcam and one for my scanner. I have
  to be able to set the handle to the scanner. Is it enough to set the
  handle to the device name or should it be set to the physical /dev/sg0
  value (which is not a good idea!)
=20
 call sane_get_devices, and use the field SANE_Device.name from the=20
 elements of device_list as the first parameter in the of call sane_open.=20
   Using something like '/dev/sg0' will not work, because Sane does not=20
 know in this case, which backend should be used; 'mustek:/dev/sg0' might=20
 work.=20

I'll give it a spin and see what happens.

Thanks for the tips. I have no doubt I'll be back to ask for more...

TTFN

Paul
--=20
Homer: Donut?=20
Lisa: No, thanks. Do you have any fruit?=20
Homer: This has purple stuff inside. Purple is a fruit.

--=-QXjUhHAZchXguKpunTzh
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQBBTXEmusSVe5EZv3wRArVlAKCPPZseX/+0jd3xHMZUzk5AbA3+aQCeMaVf
K4gA6dTPzO8Po4KtM83WzMI=
=kZ0I
-END PGP SIGNATURE-

--=-QXjUhHAZchXguKpunTzh--




[sane-devel] SANE_Handle question

2004-09-19 Thread abel deuring
Paul wrote:
 Hi,
 
 
I'm trying to implement using SANE within Scribus and I'm hitting a
small snag. While the majority of the API is really simple to use, I'm
having a problem with what SANE_Handle is.

Its great to hear that Scribus will support Sane.
 
 
 Still lots to do and a decision as to how much the support will be. Do I
 have it so that the scanner scans the image and then let GIMP deal with
 the rest or have a very basic area select mechanism? I'm happier to send
 things to GIMP, but then I'm lazy ;-p

Well, perhaps that's lazy, but reasonable: why reinvent the wheel ;)

There might be an alternative: XSane or XScanimage as a plugin for 
Scribus, similiary as you can plug these programs into Gimp. This way, 
you don't have to bother with the details of the scanning UI and of the 
Sane API, while you get what Scribus needs: a pixel image. Moreover, 
XSane has many useful features, like automatic gamma correction.

cheers
Abel



[sane-devel] SANE_Handle question

2004-09-18 Thread Paul
--=-ZDp8vv5vFSIyEv7Xlepw
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Hi,

I'm trying to implement using SANE within Scribus and I'm hitting a
small snag. While the majority of the API is really simple to use, I'm
having a problem with what SANE_Handle is.

The sane.h header has it defined as=20

typedef void *SANE_Handle;

There are plenty of functions which require SANE_Handle, but nothing
which actually sets it!

According to the sane website, SANE does not require that a value of
this type be a legal pointer value and an application shouldn't attempt
to interpret the value of SANE_Handle.

This doesn't make sense - it looks like I can quite happily send
flibble as the handle and it makes no difference (okay, I know that's
not the case...).

How should I set the handle? For instance, when I obtain the device
list, I have two show for my USB webcam and one for my scanner. I have
to be able to set the handle to the scanner. Is it enough to set the
handle to the device name or should it be set to the physical /dev/sg0
value (which is not a good idea!)

Scribus is written in C++ and use the Qt widget set. I know I could use
the kscan library, but I'd rather not (for a couple of reasons).

www.scribus.net

TTFN

Paul
--=20
Homer: Donut?=20
Lisa: No, thanks. Do you have any fruit?=20
Homer: This has purple stuff inside. Purple is a fruit.

--=-ZDp8vv5vFSIyEv7Xlepw
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQBBTJoDusSVe5EZv3wRAl9rAJ9mcy8BT3lw+JJ1ZVh3lbsj0ltQwACgi++I
Kivrg8O7dnjwsAExn9DEINk=
=OML5
-END PGP SIGNATURE-

--=-ZDp8vv5vFSIyEv7Xlepw--