Skip to content

Commit

Permalink
capture the screen once a frame (was 3 times a frame) with aero
Browse files Browse the repository at this point in the history
  • Loading branch information
entdark committed Apr 14, 2016
1 parent b4d923b commit 7a38365
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
28 changes: 20 additions & 8 deletions Musical Lights/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ Screen::~Screen(void)

ReleaseDC(NULL, screen_);
DeleteObject(bitmap_);
if (bufPixels)
delete[] bufPixels;
if (bufPixels_)
delete[] bufPixels_;
bufPixels_ = NULL;
}

void Screen::enableIlluminateEmulation(void)
Expand Down Expand Up @@ -258,11 +259,10 @@ void Screen::acquireScreenRegion(RGBColour &colour, ScreenRegion &region) {
}
}
} else {
// get the actual bitmap buffer
if (0 != GetDIBits(screen_, bitmap_, 0, bitmapInfo_.bmiHeader.biHeight, (LPVOID)bufPixels, &bitmapInfo_, DIB_RGB_COLORS)) {
if (tookScreen_) {
for (unsigned int y = minYPos + (ySeperation / 2); y < maxYPos; y += ySeperation) {
for (unsigned int x = minXPos + (xSeperation / 2); x < maxXPos; x += xSeperation) {
BYTE *pixelColour_ = bufPixels + 4 * x + y * 4 * width_;
BYTE *pixelColour_ = bufPixels_ + 4 * x + y * 4 * width_;

rgbPixel_ = RGBColour(pixelColour_[2] / 255.0f, pixelColour_[1] / 255.0f, pixelColour_[0] / 255.0f);
processor_->processPixel(colour, rgbPixel_);
Expand Down Expand Up @@ -298,6 +298,17 @@ void Screen::acquireScreenRegion(HSVColour &colour, ScreenRegion &region)
rgb.computeHSV(colour.h, colour.s, colour.v);
}

void Screen::takeAeroScreen(void) {
tookScreen_ = false;
if ((!aeroPresent_ || aeroDisabled_)) {
} else {
// get the actual bitmap buffer
if (0 != GetDIBits(screen_, bitmap_, 0, bitmapInfo_.bmiHeader.biHeight, (LPVOID)bufPixels_, &bitmapInfo_, DIB_RGB_COLORS)) {
tookScreen_ = true;
}
}
}

bool Screen::desktopCompositionPresent(void)
{
BOOL aeroStatus;
Expand Down Expand Up @@ -395,8 +406,9 @@ void Screen::reinitialiseScreen(void)

//aero support
DeleteObject(bitmap_);
if (bufPixels)
delete[] bufPixels;
if (bufPixels_)
delete[] bufPixels_;
bufPixels_ = NULL;
initDIBits();
}

Expand Down Expand Up @@ -427,7 +439,7 @@ void Screen::initDIBits(void) {
}

// create the bitmap buffer
bufPixels = new BYTE[bitmapInfo_.bmiHeader.biSizeImage];
bufPixels_ = new BYTE[bitmapInfo_.bmiHeader.biSizeImage];

// Better do this here - the original bitmap might have BI_BITFILEDS, which makes it
// necessary to read the color table - you might not want this.
Expand Down
4 changes: 3 additions & 1 deletion Musical Lights/Screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Screen

void acquireScreenRegion(RGBColour &colour, ScreenRegion &region);
void acquireScreenRegion(HSVColour &colour, ScreenRegion &region);
void takeAeroScreen(void);

bool desktopCompositionPresent(void);
bool changePixelProcessor(PixelProcessor* processor);
Expand Down Expand Up @@ -107,7 +108,8 @@ class Screen
//aero support
HBITMAP bitmap_;
BITMAPINFO bitmapInfo_;
BYTE *bufPixels;
BYTE *bufPixels_;
bool tookScreen_;

list<ColourPeriod>* colourPeriods_;
list<ColourPeriod>::iterator currentPeriod_;
Expand Down
1 change: 1 addition & 0 deletions Musical Lights/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ void System::execute(void)
screen_->reinitialiseScreen();
}

screen_->takeAeroScreen();
screen_->acquireScreenRegion(centre, ScreenRegion(0.333f, 0.667f, 0.0f, 1.0f));
screen_->acquireScreenRegion(left, ScreenRegion(0.0f, 0.333f, 0.0f, 1.0f));
screen_->acquireScreenRegion(right, ScreenRegion(0.667f, 1.0f, 0.0f, 1.0f));
Expand Down

0 comments on commit 7a38365

Please sign in to comment.