# NOT RUN {
#tkimageRead
file_path <- system.file("img", "example.png", package = "tkImgR")
im01 <- tkimageRead("tkImage01", file_path)
"tkImage01" %in% as.character(tcltk::.Tcl("image names"))
tkimageDelete(im01)
#tkimageCreate
file_path <- system.file("img", "example.png", package = "tkImgR")
im1 <- tkimageCreate("tkImage01")
tkimage.height(im1) #0
im1 <- tkimageCreate("tkImage01", file_path)
tkimage.height(im1) #2824
"tkImage01" %in% as.character(tcltk::.Tcl("image names"))
tkimageDelete(im1)
#tkimageCopy
file_path <- system.file("img", "example.png", package = "tkImgR")
im1 <- tkimageCreate("tkImage01", file_path)
im3 <- tkimageCreate("tkImage03")
tkimageCopy(im3, "tkImage01")
c("tkImage01","tkImage03") %in% as.character(tcltk::.Tcl("image names"))
tkimageDelete(im1)
tkimageDelete(im3)
#tkimageWrite
file_path <- system.file("img", "example.png", package = "tkImgR")
im1 <- tkimageCreate("tkImage01", file_path)
file_path_crop_image <- file.path(tempdir(check = TRUE), "crop.png")
#if is possible to write the file
if (file.access(file_path_crop_image)==0){
tkimageWrite(im1, file_path_crop_image, from=c(0,1500))
im1_crop <- tkimageRead("tkImage01_crop", file_path_crop_image)
print(tkimage.height(im1)) #2824
print(tkimage.height(im1_crop)) #1324 = 2824 - 1500
tkimageDelete(im1_crop)
}
#tkimageDelete
file_path <- system.file("img", "example.png", package = "tkImgR")
im1 <- tkimageCreate("tkImage01", file_path)
"tkImage01" %in% as.character(tcltk::.Tcl("image names"))
tkimageDelete(im1)
"tkImage01" %in% as.character(tcltk::.Tcl("image names"))
# }
Run the code above in your browser using DataLab