LMMS
Loading...
Searching...
No Matches
juce_mac_CoreGraphicsHelpers.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
30namespace
31{
32 template <class RectType>
33 Rectangle<int> convertToRectInt (RectType r) noexcept
34 {
35 return { (int) r.origin.x,
36 (int) r.origin.y,
37 (int) r.size.width,
38 (int) r.size.height };
39 }
40
41 template <class RectType>
42 Rectangle<float> convertToRectFloat (RectType r) noexcept
43 {
44 return { (float) r.origin.x,
45 (float) r.origin.y,
46 (float) r.size.width,
47 (float) r.size.height };
48 }
49
50 template <class RectType>
51 CGRect convertToCGRect (RectType r) noexcept
52 {
53 return CGRectMake ((CGFloat) r.getX(), (CGFloat) r.getY(), (CGFloat) r.getWidth(), (CGFloat) r.getHeight());
54 }
55
56 template <class PointType>
57 Point<float> convertToPointFloat (PointType p) noexcept
58 {
59 return { (float) p.x, (float) p.y };
60 }
61
62 template <typename PointType>
63 CGPoint convertToCGPoint (PointType p) noexcept
64 {
65 return CGPointMake ((CGFloat) p.x, (CGFloat) p.y);
66 }
67
68 template <class PointType>
69 Point<int> roundToIntPoint (PointType p) noexcept
70 {
71 return { roundToInt (p.x), roundToInt (p.y) };
72 }
73
74 #if JUCE_MAC
75 inline CGFloat getMainScreenHeight() noexcept
76 {
77 if ([[NSScreen screens] count] == 0)
78 return 0.0f;
79
80 return [[[NSScreen screens] objectAtIndex: 0] frame].size.height;
81 }
82
83 inline NSRect flippedScreenRect (NSRect r) noexcept
84 {
85 r.origin.y = getMainScreenHeight() - (r.origin.y + r.size.height);
86 return r;
87 }
88
89 inline NSPoint flippedScreenPoint (NSPoint p) noexcept
90 {
91 p.y = getMainScreenHeight() - p.y;
92 return p;
93 }
94 #endif
95}
96
97CGImageRef juce_createCoreGraphicsImage (const Image&, CGColorSpaceRef);
98CGContextRef juce_getImageContext (const Image&);
99
100#if JUCE_IOS
101 Image juce_createImageFromUIImage (UIImage*);
102#endif
103
104#if JUCE_MAC
105 NSImage* imageToNSImage (const ScaledImage& image);
106#endif
107
108} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_Image.h:58
Definition juce_ScaledImage.h:45
Definition carla_juce.cpp:31
CGImageRef juce_createCoreGraphicsImage(const Image &, CGColorSpaceRef)
CGContextRef juce_getImageContext(const Image &)
int roundToInt(const FloatType value) noexcept
Definition juce_MathsFunctions.h:465
uch * p
Definition crypt.c:594
int r
Definition crypt.c:458
typedef int(UZ_EXP MsgFn)()
_WDL_CSTRING_PREFIX void INT_PTR count
Definition wdlcstring.h:263