Message Boards Message Boards

Convert a graphic type variable into an image?

Posted 6 years ago

Dear all,

I want to convert a Graphic type variable into an image. For example, I'm trying the following code to convert a simple graphics,

{PointSize[Small], Point[{1, 1}], Point[{0, 0}]} //Graphics[#, ImageSize -> {512, 512}] & // ColorNegate

The problem is that the two points are not really in the corner of the image. How can I fix the problem? Please note that this example is a toy example.

Thank you, Luis

POSTED BY: Luis Mendes
Posted 6 years ago

I think specifying the proper PlotRange explicitly may get you what you're after:

Graphics[{PointSize[Small], Point[{1, 1}], Point[{0, 0}]}, 
  ImageSize -> {25, 25}, PlotRange -> {{0, 1}, {0, 1}}] // ColorNegate

image

The default value of PlotRange seems to add a little extra "padding" past the outermost points, which in other cases would be desirable.

(I changed the ImageSize to make it more clear where the points were ending up)

POSTED BY: Kyle Martin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract