コード例 #1
0
ファイル: _dev_test.go プロジェクト: felixonmars/dde-daemon
func snapshotNotify(suffix string) {
	time.Sleep(1 * time.Second)
	os.MkdirAll("testresult", 0755)
	resultScreenFile := "testresult/test_network_screen.png"
	resultClipFile := "testresult/test_network_" + suffix + ".png"
	gdkpixbuf.ScreenshotImage(resultScreenFile, gdkpixbuf.FormatPng)
	sw, _, _ := gdkpixbuf.GetImageSize(resultScreenFile)
	pading := 35
	w, h := 300-2, 70-2
	gdkpixbuf.ClipImage(resultScreenFile, resultClipFile, sw-pading-w, pading, w, h, gdkpixbuf.FormatPng)
}
コード例 #2
0
ファイル: theme.go プロジェクト: felixonmars/dde-daemon
// Fix issue that the theme background will keep default size as
// 1024x768 if updating grub-themes-deepin package lonely
func (theme *Theme) regenerateBackgroundIfNeed() {
	logger.Debug("check if need regenerate theme background")
	wantWidth, wantHeight := parseCurrentGfxmode()
	bgw, bgh, _ := graphic.GetImageSize(theme.bgFile)
	srcbgw, srcbgh, _ := graphic.GetImageSize(theme.bgSrcFile)
	needGenerate := false
	logger.Debugf("expected size: %dx%d, source background: %dx%d, background: %dx%d",
		wantWidth, wantHeight, srcbgw, srcbgh, bgw, bgh)
	if srcbgw >= int(wantWidth) && srcbgh >= int(wantHeight) {
		// if source background is bigger than expected size, the size
		// of background should equal with it
		if delta(float64(bgw), float64(wantWidth)) > 5 ||
			delta(float64(bgh), float64(wantHeight)) > 5 {
			needGenerate = true
		}
	} else {
		// if source background is smaller than expected size, the
		// scale of backgound should equle with it
		scalebg := float64(bgw) / float64(bgh)
		scaleScreen := float64(wantWidth) / float64(wantHeight)
		if delta(scalebg, scaleScreen) > 0.1 {
			needGenerate = true
		}
	}

	// regenerate theme background if thumbnail not exists
	if !utils.IsFileExist(theme.bgThumbFile) {
		needGenerate = true
	}

	if needGenerate {
		grub2extDoGenerateThemeBackground(wantWidth, wantHeight)
		theme.setPropBackground(theme.bgThumbFile)
		logger.Info("update theme background success")
	}
}
コード例 #3
0
ファイル: grub2ext.go プロジェクト: felixonmars/dde-daemon
// DoGenerateThemeBackground generate the background for deepin grub2
// theme depends on screen resolution.
func (ge *Grub2Ext) DoGenerateThemeBackground(screenWidth, screenHeight uint16) (ok bool, err error) {
	imgWidth, imgHeight, err := graphic.GetImageSize(themeBgSrcFile)
	if err != nil {
		logger.Error(err)
		return false, err
	}
	logger.Infof("source background size %dx%d", imgWidth, imgHeight)
	logger.Infof("background size %dx%d", screenWidth, screenHeight)
	err = graphic.ScaleImagePrefer(themeBgSrcFile, themeBgFile, int(screenWidth), int(screenHeight), graphic.GDK_INTERP_HYPER, graphic.FormatPng)
	if err != nil {
		logger.Error(err)
		return false, err
	}

	// generate background thumbnail
	err = graphic.ThumbnailImage(themeBgFile, themeBgThumbFile, 300, 300, graphic.GDK_INTERP_BILINEAR, graphic.FormatPng)
	if err != nil {
		logger.Error(err)
		return false, err
	}

	return true, nil
}