Skip to content

Commit

Permalink
Updated mac build
Browse files Browse the repository at this point in the history
  • Loading branch information
smasherprog committed Jul 11, 2017
1 parent 6e6ed74 commit fd832f9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
10 changes: 5 additions & 5 deletions Example/Screen_Capture_Example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ void createframegrabber()
for (auto& m : mons) {
// capture just a 512x512 square... USERS SHOULD MAKE SURE bounds are
// valid!!!!

/* m.OffsetX += 512;
/*
m.OffsetX += 512;
m.OffsetY += 512;
m.Height = 512;
m.Width = 512;*/

m.Width = 512;
*/
std::cout << m << std::endl;
}
return mons;
Expand Down Expand Up @@ -66,7 +66,7 @@ void createframegrabber()
auto size = RowStride(img) * Height(img);
//auto imgbuffer(std::make_unique<char[]>(size));
// Extract(img, imgbuffer.get(), size);
//ExtractAndConvertToRGBA(img, imgbuffer.get(), size);
// ExtractAndConvertToRGBA(img, imgbuffer.get(), size);

if (std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::high_resolution_clock::now() - onNewFramestart)
Expand Down
2 changes: 1 addition & 1 deletion include/ios/CGFrameProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace SL {
public:

DUPL_RETURN Init(std::shared_ptr<Thread_Data> data, Monitor& monitor);
DUPL_RETURN ProcessFrame();
DUPL_RETURN ProcessFrame(const Monitor& curentmonitorinfo);

};

Expand Down
25 changes: 18 additions & 7 deletions src/ios/CGFrameProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,30 @@ namespace SL {
//
// Process a given frame and its metadata
//
DUPL_RETURN CGFrameProcessor::ProcessFrame()
DUPL_RETURN CGFrameProcessor::ProcessFrame(const Monitor& curentmonitorinfo)
{
auto Ret = DUPL_RETURN_SUCCESS;
auto imageRef = CGDisplayCreateImage(Id(SelectedMonitor));

CGImageRef imageRef;

if(Height(curentmonitorinfo) != Height(SelectedMonitor) || Width(curentmonitorinfo) != Width(SelectedMonitor)){
CGRect rec;
rec.origin.y =OffsetY(SelectedMonitor);
rec.origin.x =OffsetX(SelectedMonitor);
rec.size.width =Width(SelectedMonitor);
rec.size.height =Height(SelectedMonitor);

imageRef = CGDisplayCreateImageForRect(Id(SelectedMonitor), rec);
} else {
imageRef = CGDisplayCreateImage(Id(SelectedMonitor));
}


if(!imageRef) return DUPL_RETURN_ERROR_EXPECTED;//this happens when the monitors change.

auto width = CGImageGetWidth(imageRef);
auto height = CGImageGetHeight(imageRef);
if(width!= Width(SelectedMonitor) || height!= Height(SelectedMonitor)){
CGImageRelease(imageRef);
return DUPL_RETURN_ERROR_EXPECTED;//this happens when the monitors change.
}


auto prov = CGImageGetDataProvider(imageRef);
if(!prov){
CGImageRelease(imageRef);
Expand Down

0 comments on commit fd832f9

Please sign in to comment.