[PATCH] Re: Graphics: file loading problems

2002-04-15 Thread R. Lahaye

Angus Leeming wrote:
 
 Bingo! xforms 0.88 has noimage  support. You're using the image loader I
 wrote based on the libXpm library. The relevant code is to be found in
 src/graphics/GraphicsImageXPM.C.
 
$Bingo^2$ !! Thanks for your hints and help.

Instead of
 
   dimension const * start_row = old_data;

we need

dimension const * start_row = old_data
+ image_.width() * (image_.height() - params.bb.yt);

Please apply attached patch!

Regards,
Rob.


graphics.diff.gz
Description: GNU Zip compressed data


Re: [PATCH] Re: Graphics: file loading problems

2002-04-15 Thread Angus Leeming

On Monday 15 April 2002 4:22 pm, R. Lahaye wrote:
 Angus Leeming wrote:
  Bingo! xforms 0.88 has noimage  support. You're using the image loader I
  wrote based on the libXpm library. The relevant code is to be found in
  src/graphics/GraphicsImageXPM.C.

 $Bingo^2$ !! Thanks for your hints and help.

 Instead of

dimension const * start_row = old_data;

 we need

 dimension const * start_row = old_data
 + image_.width() * (image_.height() -
 params.bb.yt);

dimension const * start_row = old_data + image_.width() * 
(image_.height() - params.bb.yt);

Excuse me a momement, but why is that:
(image_.height() - params.bb.yt)
not
params.bb.yb
?

Angus



Re: [PATCH] Re: Graphics: file loading problems

2002-04-15 Thread R. Lahaye

Angus Leeming wrote:
 
 On Monday 15 April 2002 4:22 pm, R. Lahaye wrote:
  Angus Leeming wrote:
   Bingo! xforms 0.88 has noimage  support. You're using the image loader I
   wrote based on the libXpm library. The relevant code is to be found in
   src/graphics/GraphicsImageXPM.C.
 
  $Bingo^2$ !! Thanks for your hints and help.
 
  Instead of
 
 dimension const * start_row = old_data;
 
  we need
 
  dimension const * start_row = old_data
  + image_.width() * (image_.height() -
  params.bb.yt);
 
 dimension const * start_row = old_data + image_.width() *
 (image_.height() - params.bb.yt);
 
 Excuse me a momement, but why is that:
 (image_.height() - params.bb.yt)
 not
 params.bb.yb
 ?

Ah, took me also some time to realize.
The picture is stored in memory from upper-left to lower-right
(see attachement).
Horizontally you still run from xl to xr, but vertically
you run from yt to yb, NOT reversed as you're thinking.
So you have to recalculate from the top, not the bottom.
The top is height - yt.

Does that make sense to you?

The patch works beautifully here!

Regards,
Rob.



 Angus

-- 
dr. R.J.W.E. Lahaye
Center for Ion-Surface Reaction 
Department of Chemistry
Pohang University of Science and Technology
San 31 Hyojadong, Namgu
790-784 Pohang, Kyungbuk
Republic of Korea

Tel : +82-54-279-2780
Fax : +82-54-279-8157
email: [EMAIL PROTECTED]



Re: [PATCH] Re: Graphics: file loading problems

2002-04-15 Thread Angus Leeming

On Monday 15 April 2002 5:37 pm, R. Lahaye wrote:
  Excuse me a momement, but why is that:
  (image_.height() - params.bb.yt)
  not
  params.bb.yb
  ?

 Ah, took me also some time to realize.
 The picture is stored in memory from upper-left to lower-right
 (see attachement).
 Horizontally you still run from xl to xr, but vertically
 you run from yt to yb, NOT reversed as you're thinking.
 So you have to recalculate from the top, not the bottom.
 The top is height - yt.

 Does that make sense to you?

Indeed. I probably knew this once upon a time, but my mind is like a seive 
and it's easier to question than to remember.

 The patch works beautifully here!

And here. I'll apply presently.
Angus


 Regards,
 Rob.

  Angus



[PATCH] Re: Graphics: file loading problems

2002-04-15 Thread R. Lahaye

Angus Leeming wrote:
> 
> Bingo! xforms 0.88 has noimage  support. You're using the image loader I
> wrote based on the libXpm library. The relevant code is to be found in
> src/graphics/GraphicsImageXPM.C.
 
$Bingo^2$ !! Thanks for your hints and help.

Instead of
 
   dimension const * start_row = old_data;

we need

dimension const * start_row = old_data
+ image_.width() * (image_.height() - params.bb.yt);

Please apply attached patch!

Regards,
Rob.


graphics.diff.gz
Description: GNU Zip compressed data


Re: [PATCH] Re: Graphics: file loading problems

2002-04-15 Thread Angus Leeming

On Monday 15 April 2002 4:22 pm, R. Lahaye wrote:
> Angus Leeming wrote:
> > Bingo! xforms 0.88 has noimage  support. You're using the image loader I
> > wrote based on the libXpm library. The relevant code is to be found in
> > src/graphics/GraphicsImageXPM.C.
>
> $Bingo^2$ !! Thanks for your hints and help.
>
> Instead of
>
>dimension const * start_row = old_data;
>
> we need
>
> dimension const * start_row = old_data
> + image_.width() * (image_.height() -
> params.bb.yt);

dimension const * start_row = old_data + image_.width() * 
(image_.height() - params.bb.yt);

Excuse me a momement, but why is that:
(image_.height() - params.bb.yt)
not
params.bb.yb
?

Angus



Re: [PATCH] Re: Graphics: file loading problems

2002-04-15 Thread R. Lahaye

Angus Leeming wrote:
> 
> On Monday 15 April 2002 4:22 pm, R. Lahaye wrote:
> > Angus Leeming wrote:
> > > Bingo! xforms 0.88 has noimage  support. You're using the image loader I
> > > wrote based on the libXpm library. The relevant code is to be found in
> > > src/graphics/GraphicsImageXPM.C.
> >
> > $Bingo^2$ !! Thanks for your hints and help.
> >
> > Instead of
> >
> >dimension const * start_row = old_data;
> >
> > we need
> >
> > dimension const * start_row = old_data
> > + image_.width() * (image_.height() -
> > params.bb.yt);
> 
> dimension const * start_row = old_data + image_.width() *
> (image_.height() - params.bb.yt);
> 
> Excuse me a momement, but why is that:
> (image_.height() - params.bb.yt)
> not
> params.bb.yb
> ?

Ah, took me also some time to realize.
The picture is stored in memory from upper-left to lower-right
(see attachement).
Horizontally you still run from xl to xr, but vertically
you run from yt to yb, NOT reversed as you're thinking.
So you have to recalculate from the top, not the bottom.
The top is "height - yt".

Does that make sense to you?

The patch works beautifully here!

Regards,
Rob.



> Angus

-- 
dr. R.J.W.E. Lahaye
Center for Ion-Surface Reaction 
Department of Chemistry
Pohang University of Science and Technology
San 31 Hyojadong, Namgu
790-784 Pohang, Kyungbuk
Republic of Korea

Tel : +82-54-279-2780
Fax : +82-54-279-8157
email: [EMAIL PROTECTED]



Re: [PATCH] Re: Graphics: file loading problems

2002-04-15 Thread Angus Leeming

On Monday 15 April 2002 5:37 pm, R. Lahaye wrote:
> > Excuse me a momement, but why is that:
> > (image_.height() - params.bb.yt)
> > not
> > params.bb.yb
> > ?
>
> Ah, took me also some time to realize.
> The picture is stored in memory from upper-left to lower-right
> (see attachement).
> Horizontally you still run from xl to xr, but vertically
> you run from yt to yb, NOT reversed as you're thinking.
> So you have to recalculate from the top, not the bottom.
> The top is "height - yt".
>
> Does that make sense to you?

Indeed. I probably knew this once upon a time, but my mind is like a seive 
and it's easier to question than to remember.
>
> The patch works beautifully here!

And here. I'll apply presently.
Angus

>
> Regards,
> Rob.
>
> > Angus



[PATCH] Re: Graphics: file loading problems

2002-04-12 Thread Herbert Voss

Angus Leeming wrote:


 I'm sure someone, somewhere, will tell us to use the std algorithms, rather 
 than roll our own loops, but the above (or something close to it) should work.
 
 Alternatively, why not just add agr to that string!


here is the alternative:


Herbert



-- 
http://www.lyx.org/help/


Index: src/frontends/controllers/ChangeLog
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ChangeLog,v
retrieving revision 1.158
diff -u -r1.158 ChangeLog
--- src/frontends/controllers/ChangeLog 11 Apr 2002 17:40:44 -  1.158
+++ src/frontends/controllers/ChangeLog 12 Apr 2002 14:39:27 -
@@ -1,5 +1,9 @@
 2002-04-11  Herbert Voss  [EMAIL PROTECTED]
 
+   * ControlGraphics.C: expand browse-string to all available formats
+
+2002-04-11  Herbert Voss  [EMAIL PROTECTED]
+
* ControlGraphics.C: read BoundingBox also from non (e)ps files.
 
 2002-04-08  Adrien Rebollo  [EMAIL PROTECTED]
Index: src/frontends/controllers/ControlGraphics.C
===
RCS file: 
/usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlGraphics.C,v
retrieving revision 1.32
diff -u -r1.32 ControlGraphics.C
--- src/frontends/controllers/ControlGraphics.C 11 Apr 2002 17:40:44 -  1.32
+++ src/frontends/controllers/ControlGraphics.C 12 Apr 2002 14:39:28 -
@@ -46,6 +46,18 @@
 using std::pair;
 using std::make_pair;
 using std::ifstream;
+
+namespace {
+
+// FIXME: currently we need the second '|' to prevent mis-interpretation!
+// All supported graphic formats with their file-extension and the
+// gzip-ext for zipped (e)ps-files.
+string const grfx_pattern = 
+   *.(agr|bmp|eps|epsi|fits|gif|jpg|obj|pdf|pbm|pgm|png|
+   ppm|ps|tif|tiff|xbm|xpm|xwd|gz)|; 
+
+}
+
  
 ControlGraphics::ControlGraphics(LyXView  lv, Dialogs  d)
: ControlInsetInsetGraphics, InsetGraphicsParams(lv, d)
@@ -90,8 +102,6 @@
 string const ControlGraphics::Browse(string const  in_name)
 {
string const title = _(Select graphics file);
-   // FIXME: currently we need the second '|' to prevent mis-interpretation
-   string const pattern = *.(ps|eps|png|jpeg|jpg|gif|gz)|;
 
// Does user clipart directory exist?
string clipdir = AddName (user_lyxdir, clipart);
@@ -103,7 +113,7 @@
pairstring, string dir2(_(Documents|#o#O), string(lyxrc.document_path));
// Show the file browser dialog
return browseRelFile(lv_, in_name, lv_.buffer()-filePath(),
-title, pattern, dir1, dir2);
+title, ::grfx_pattern, dir1, dir2);
 }
 
 



[PATCH] Re: Graphics: file loading problems

2002-04-12 Thread Herbert Voss

Angus Leeming wrote:


> I'm sure someone, somewhere, will tell us to use the std algorithms, rather 
> than roll our own loops, but the above (or something close to it) should work.
> 
> Alternatively, why not just add "agr" to that string!


here is the alternative:


Herbert



-- 
http://www.lyx.org/help/


Index: src/frontends/controllers/ChangeLog
===
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ChangeLog,v
retrieving revision 1.158
diff -u -r1.158 ChangeLog
--- src/frontends/controllers/ChangeLog 11 Apr 2002 17:40:44 -  1.158
+++ src/frontends/controllers/ChangeLog 12 Apr 2002 14:39:27 -
@@ -1,5 +1,9 @@
 2002-04-11  Herbert Voss  <[EMAIL PROTECTED]>
 
+   * ControlGraphics.C: expand "browse-string" to all available formats
+
+2002-04-11  Herbert Voss  <[EMAIL PROTECTED]>
+
* ControlGraphics.C: read BoundingBox also from non (e)ps files.
 
 2002-04-08  Adrien Rebollo  <[EMAIL PROTECTED]>
Index: src/frontends/controllers/ControlGraphics.C
===
RCS file: 
/usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ControlGraphics.C,v
retrieving revision 1.32
diff -u -r1.32 ControlGraphics.C
--- src/frontends/controllers/ControlGraphics.C 11 Apr 2002 17:40:44 -  1.32
+++ src/frontends/controllers/ControlGraphics.C 12 Apr 2002 14:39:28 -
@@ -46,6 +46,18 @@
 using std::pair;
 using std::make_pair;
 using std::ifstream;
+
+namespace {
+
+// FIXME: currently we need the second '|' to prevent mis-interpretation!
+// All supported graphic formats with their file-extension and the
+// gzip-ext for zipped (e)ps-files.
+string const grfx_pattern = 
+   "*.(agr|bmp|eps|epsi|fits|gif|jpg|obj|pdf|pbm|pgm|png|"
+   "ppm|ps|tif|tiff|xbm|xpm|xwd|gz)|"; 
+
+}
+
  
 ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d)
: ControlInset(lv, d)
@@ -90,8 +102,6 @@
 string const ControlGraphics::Browse(string const & in_name)
 {
string const title = _("Select graphics file");
-   // FIXME: currently we need the second '|' to prevent mis-interpretation
-   string const pattern = "*.(ps|eps|png|jpeg|jpg|gif|gz)|";
 
// Does user clipart directory exist?
string clipdir = AddName (user_lyxdir, "clipart");
@@ -103,7 +113,7 @@
pair dir2(_("Documents|#o#O"), string(lyxrc.document_path));
// Show the file browser dialog
return browseRelFile(_, in_name, lv_.buffer()->filePath(),
-title, pattern, dir1, dir2);
+title, ::grfx_pattern, dir1, dir2);
 }