# drawing an image on the center of the screen (ptb 3, osx)

**URL:** <https://psychtoolbox.discourse.group/t/drawing-an-image-on-the-center-of-the-screen-ptb-3-osx/1236>\
**Category:** Uncategorized\
**Created:** [March 6, 2007, 2:55am UTC](https://psychtoolbox.discourse.group/t/drawing-an-image-on-the-center-of-the-screen-ptb-3-osx/1236 "2007-03-06T02:55:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![josephpaxton](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@josephpaxton](https://psychtoolbox.discourse.group/u/josephpaxton)\
**Post date:** [March 6, 2007, 2:55am UTC](https://psychtoolbox.discourse.group/t/drawing-an-image-on-the-center-of-the-screen-ptb-3-osx/1236/1 "2007-03-06T02:55:12Z")

</div>

Hello All,  
  
What is the standard / most straightforward way of drawing an image   
(e.g., a jpg) on the center of the screen in PTB 3 on OSX? I see that   
there is a function that does this for text (DrawFormattedText).   
However, it looks like you have to manually specify screen   
coordinates by passing the "rect" argument to Screen DrawTexture in   
order to center an image.  
  
It's easy enough to manually determine those coordinates by trial-and-   
error. I take it, though, that there is a way to 1.) calculate how   
big the rect needs to be based on the size of your image file and 2.)   
figure out where to place the rect in order to center it on the basis   
of the parameters of your particular screen and the size of the rect.   
But I'm completely flummoxed when it comes to actually doing these   
two things.  
  
General guidelines would be very much appreciated. Sample code would   
be wonderful.  
  
Thanks!  
Joe Paxton  
  
--  
Joseph M. Paxton  
Research Assistant  
Department of Psychology  
William James 1482  
33 Kirkland Street  
Harvard University  
Cambridge, MA 02138  
Phone: 617-495-3878
