我一直在使用此代码来复制多个范围和图表。然而,随着我的代码的增长,它似乎失败了,在搜索了这个问题后,我认为这是由于图表/范围没有正确复制到剪贴板缓存/从剪贴板缓存复制而来。有没有办法避免这个错误?
错误 - “运行时错误'-2147188160(80048248)':Shapes.PasteSpecial:无效请求。剪贴板为空或包含可能无法粘贴到此处的数据”
Public Sub CopyPasteHeadcountTopGraph()
If PPT Is Nothing Then Exit Sub
If PPT_pres Is Nothing Then Exit Sub
Dim rng As Range
Dim mySlide As Object
Dim myShape As Object
Dim cht As Chart
Set mySlide = PPT_pres.Slides(6)
With mySlide
.Select
Set cht = ThisWorkbook.Worksheets("Headcount").ChartObjects("HcChart").Chart
cht.CopyPicture Appearance:=xlScreen, Format:=xlPicture, Size:=xlScreen
.Shapes.Paste.Select 'ERROR HERE
'''''''''''''''''''''''''''''''''
'Paste as Chart and break link. '
'''''''''''''''''''''''''''''''''
'cht.ChartArea.Copy
'.Shapes.Paste.Select
'With .Shapes("HcChart")
'.LinkFormat.BreakLink
'End With
PPT_pres.Windows(1).Selection.ShapeRange.Left = 35
PPT_pres.Windows(1).Selection.ShapeRange.Top = 110
PPT_pres.Windows(1).Selection.ShapeRange.Width = 655 …Run Code Online (Sandbox Code Playgroud) 我目前正在从一组图像中读取 BGR 值,
我使用了各种 imread 标志,但我似乎无法将其拉为 BGRA。
我当前的代码是
import cv2
import os
#returns an list of images, list of x, list of y, list of BGR
def load_images_from_folder(folder):
images = []
for filename in os.listdir(folder):
img = cv2.imread(os.path.join(folder,filename),flags=cv2.IMREAD_UNCHANGED)
if img is not None:
images.append(img)
return images
Run Code Online (Sandbox Code Playgroud)
这返回了array([245, 247, 255], dtype=uint8)我期待的地方array([245, 247, 255, 0.2], dtype=uint8)