1

so, I am editing rtf documents and adding somes images in them.

I found this topic that help me adding the picture. But I do not understand, nor succeeding add it at the good scale.

It is add, with default a scale of 6, but even if I try adding a scale 100, it doesn't work and still at 6.

Here is what I do :

string mpic = @"{\pict\jpegblip\picw" +
                                                    returnImage.Width.ToString() + @"\pich" + returnImage.Height.ToString() +
                                                    @"\picwgoal" + returnImage.Width.ToString() + @"\pichgoal" + returnImage.Height.ToString() +
                                                    @"\picscalex" + 100.ToString() + @"\picscaley" + 100.ToString() +
                                                    @"\hex " + str + "}";

(of course, I also tried @"\picscaley100", same result)

So basically, I just add the image, and specify the scale.

I read that it is a 100% as default, but when I do not a the scale, it still 6 %, and when I add the scale, no changement.

It is obvisously not the good wsay, but I do not found example with a full line.

I think I forgot an important part : this string, replace another string in the document. And the document, I s covnert from byte to a string, so that I can modifiy my document.

                    using (var file = new MemoryStream(text))
                    using (var reader = new StreamReader(file))
                    {
                        //on se place au début du document à lire
                        reader.BaseStream.Seek(0, SeekOrigin.Begin);
                        //tant que la lecture n'est pas rendu à la fin du document on continue
                        while (!reader.EndOfStream)
                        {
                            //ecriture de chaque ligne du byte dans une string
                            contenu += reader.ReadLine();
                        }
                    }



myString.Replace("myImage", mpic);

And It can be a reason.

Here are the differences, after modifiyng the scale with word :

pic1 pic2 pic3

Community
  • 1
  • 1
provençal le breton
  • 1,428
  • 4
  • 26
  • 43

2 Answers2

0

According to the RTF file format documentation (http://latex2rtf.sourceforge.net/RTF-Spec-1.0.txt):

\picscalex The horizontal scaling value; the argument is a value representing a percentage (the default is 100).

\picscaley The vertical scaling value; the argument is a value representing a percentage (the default is 100).

Since you are using this parameter correctly, my guess is that either there is an issue with the way the image + tags are being formatted so they aren't getting read correctly or there is an issue with the program that is opening the file.

The easiest way to diagnose a file format is to use an editor to format the file correctly for you. To do this, open your output file in an editor (aka "Word"), resize the image, then save a new copy of the file. Compare that updated file with your original and it should assist you in determining the appropriate way to format the file. In case you need a compare tool you could use beyond compare: http://www.scootersoftware.com/. Just make sure to set it to text or binary mode.

drew_w
  • 10,320
  • 4
  • 28
  • 49
  • Using winmerge, I only found one difference, the value in picscale... Yes, I think it is not added the good way. But the question is : how can I correct this? – provençal le breton May 05 '14 at 12:37
  • comment to your additional note : already tried without the scale parameters, and I got 6 as value in the scale, and I don't think picgoal is optional, no? – provençal le breton May 05 '14 at 12:38
  • @Zaphod Can you post the difference? (Either a screen shot or text with the two areas that are different) – drew_w May 05 '14 at 12:39
  • Add tree images : on the left, scale 6, on the right after modifiying with word. the tree left part are the same document, cut in 3, because I cannot screenshot fully in one pic. – provençal le breton May 05 '14 at 12:45
  • @Zaphod By "the two params", which two are you talking about? Either way - glad you figured this out! – drew_w May 06 '14 at 12:10
  • I was talking about the picscale and the picgoal, that you were takling about. But removing the two at the same time, not just one. – provençal le breton May 06 '14 at 12:18
0

The picwgoal and pichgoal parameters should be specified in the twips units (1440 twips = 1 inch). So for example, if you need the picture to be 3x2 inches, this is how your RTF tag should appear:

\picwgoal4320\pichgoal2880\picscalex100\picscaley100

1440 * 3 inches = 4320

1440 * 2 inches = 2880

The scaling is applied to the picwgoal and pichgoal parameters. Since the above example uses 100% for the scale, the picscalex/picscaley will be simply ignored.

You are seeing the picture shown at 6% because you are passing the pixel width/height to the picwgoal/pichgoal parameters. For standard monitor at 96 DPI, 96 is about 6% of 1440.

If you don't want to specify a target picture size, simply omit the picwgoal and pichgoal parameters. An RTF reader is expected to then show the picture at its full size.

user2373071
  • 310
  • 5
  • 10