Provide example code:
func TakeScreenshot(vendorID string, integrationType string, subVendor string) (filename string, err error) {
screenWidth, screenHeight := robotgo.GetScreenSize()
// Capture a screenshot of the entire screen
ct := time.Now()
screenshot := robotgo.CaptureScreen(0, 0, screenWidth, screenHeight)
fileName := fmt.Sprintf("%s%s%s_%s.png", subVendor, integrationType, vendorID, ct.Format("15_04_05"))
// Save the screenshot as a PNG file
robotgo.SaveBitmap(screenshot, "tmp/"+fileName)
// defer os.Remove(fileName) // Remove the local screenshot file when done
// Upload to S3 bucket using PutObject API call
sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
}))
my screen shot function work fine but When I tried to open my screen shot it shows like purple and green background.![cosco_ui-login_3_12_14_16](https://github.com/go-vgo/robotgo/assets/81792348/c5225a2f-03cb-4454-863e-ae0042f5e999)
Provide example code: func TakeScreenshot(vendorID string, integrationType string, subVendor string) (filename string, err error) { screenWidth, screenHeight := robotgo.GetScreenSize()
// Capture a screenshot of the entire screen ct := time.Now() screenshot := robotgo.CaptureScreen(0, 0, screenWidth, screenHeight) fileName := fmt.Sprintf("%s%s%s_%s.png", subVendor, integrationType, vendorID, ct.Format("15_04_05"))
// Save the screenshot as a PNG file robotgo.SaveBitmap(screenshot, "tmp/"+fileName) // defer os.Remove(fileName) // Remove the local screenshot file when done
file, err := os.Open("tmp/" + fileName) if err != nil { return fileName, err } defer file.Close()
// Upload to S3 bucket using PutObject API call sess := session.Must(session.NewSessionWithOptions(session.Options{ SharedConfigState: session.SharedConfigEnable, }))
svc := s3.New(sess) bucketName := os.Getenv("s3Bucket") _, err = svc.PutObject(&s3.PutObjectInput{ Bucket: aws.String(bucketName), Key: aws.String("errors/" + fileName), Body: file, }) if err != nil { return fileName, err }
return fileName, nil }
Description
I am getting the screenshot with green, purple background.