Want more features on Pastebin? Sign Up, it's FREE!
Guest

Wallpaper code

By: a guest on May 14th, 2013  |  syntax: MatLab  |  size: 1.43 KB  |  views: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. %Resolution of monitors. Monitor 1 is on the left
  2. p1x = 1440;
  3. p1y = 900;
  4. p2x = 1980;
  5. p2y = 1080;
  6.  
  7. %Diagonal sizes in inches
  8. diag1 = 19;
  9. diag2 = 23.6;
  10.  
  11. D1 = sqrt(p1x^2 + p1y^2);
  12. D2 = sqrt(p2x^2 + p2y^2);
  13.  
  14. %Scaling ratio - higher values mean the wallpaper is larger than the
  15. %monitor, but scaled down when set as a background
  16. aaratio = 1.59;
  17.  
  18. %Calculates the microns per pixel for each monitor
  19. mpp1 = diag1*25400/D1;
  20. mpp2 = diag2*25400/D2;
  21.  
  22. pixels1x = round(p1x*mpp1/mpp2*aaratio);
  23. pixels1y = round(p1y*mpp1/mpp2*aaratio);
  24.  
  25. pixels2x = round(p2x*aaratio);
  26. pixels2y = round(p2y*aaratio);
  27.  
  28. %The offset from the corner of the image to take the first corner of the
  29. %first monitor
  30. offsetx = 1;
  31. offsety = 1500;
  32.  
  33. %The gap in pixels between the two monitors
  34. gapx = round(150*aaratio);
  35. gapy = round(-110*aaratio);
  36.  
  37. I = imread('inputfilename.jpg');
  38.  
  39. I1 = I(offsety:offsety + pixels1y - 1, offsetx:offsetx + pixels1x - 1,:);
  40. I2 = I(offsety + gapy:offsety + gapy + pixels2y - 1, offsetx + pixels1x + gapx:offsetx + pixels1x + gapx + pixels2x - 1,:);
  41.  
  42. imagesc(I)
  43. rectangle('Position', [offsetx offsety pixels1x - 1 pixels1y - 1], 'EdgeColor', 'white')
  44. rectangle('Position', [(offsetx + pixels1x + gapx) (offsety + gapy) pixels2x - 1 pixels2y - 1], 'EdgeColor', 'white')
  45. rectangle('Position', [1 1 offsetx offsety], 'LineStyle', '--', 'EdgeColor', 'white')
  46.  
  47. imwrite(I1, 'outputfilename.jpg', 'jpg')
  48. imwrite(I2, 'outputfilename.jpg', 'jpg')
clone this paste RAW Paste Data