Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Since a few days I am trying to find a solution for the folowing problem: I am creating a Tikz picture with a simple rectangele and fill the rectange with a special RGB color. The code looks like this:

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\fill[color={rgb:red,50;green,5;blue,5}](0.0,0.0)--(0.0,20.0)--(15.0,20.0)--(15.0,0.0)--(0.0,0.0);
\end{tikzpicture}
\end{document}

Then I create a PNG from this Pdf file with a Shell Skript:

gs -r200x200 -sDEVICE=png16 -sOutputFile=test.png -dBATCH -dNOPAUSE test.pdf

At last I read the output image with Java and read the RGB Color of a pixel inside the rectangle. The resulting color values have alwys a big difference to the value I have set in TikZ. I think the problem is somewhere in ghost script. I would be happy of any ideas to solve this.

share|improve this question
    
Welcome to TeX.SX. A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it). –  Harish Kumar May 22 '12 at 23:34
add comment

1 Answer

You have to define the color something like this

\definecolor{mycolor}{rgb}{.5,.05,.05}

One more possibility is to use RGB where you have to give numbers from 0 to 255.

\definecolor{mycolor}{RGB}{128,15,15}

This needs the package xcolor (which is loaded by tikz in this case).

Then your tikz code becomes

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\definecolor{mycolor}{rgb}{.5,.05,.05}
%\definecolor{mycolor}{RGB}{128,15,15}
\begin{document}
\begin{tikzpicture}
\fill[color=mycolor](0.0,0.0)--(0.0,20.0)--(15.0,20.0)--(15.0,0.0)--(0.0,0.0);
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Great, now it works. Cant believe that this was the problem. –  Rua_de_Janeiro May 22 '12 at 23:49
1  
@Rua_de_Janeiro: In that case you may upvote theanswer (with the upward pointing arrow to the left of it; you need 15 reputation points before you can upvote) and accept it (by clicking on the checkmark). This will add some reputation points to those who answered and to you. This the tradition followed here in TeX.SX. –  Harish Kumar May 22 '12 at 23:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.