所以我试图用C++代码导出一个.bmp文件,除了一个主要的东西之外我还有它工作:行填充.我不是100%肯定线填充的工作原理,但我知道我需要它.我的算法工作除了填充,我在十六进制编辑器中手动添加填充到我导出的图像,它工作.但是我该如何添加填充?这是我有的:
//Size of the file in bytes
int fileSize = 54 + (3 * width * height);
//The sections of the file
unsigned char generalHeader[14] = {'B','M',0,0, 0,0,0,0, 0,0,54,0, 0,0};
unsigned char DIBHeader[40] = {40,0,0,0, 0,0,0,0, 0,0,0,0, 1,0,24,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
unsigned char pixelArray[1000000];
unsigned char bmpPad[3] = {0, 0, 0};
//Set the binary portion of the generalHeader, mainly just file size
generalHeader[2] = (unsigned char)(fileSize);
generalHeader[3] = (unsigned char)(fileSize >> 8);
generalHeader[4] = (unsigned char)(fileSize >> …Run Code Online (Sandbox Code Playgroud) 所以我试图通过SMTPlib用Python发送电子邮件,但我无法让它工作.我阅读了Microsoft SMTP规范,并相应地将它们放入,但我无法让它工作.这是我的代码:
# Send an email
SERVER = "smtp-mail.outlook.com"
PORT = 587
USER = "******@outlook.com"
PASS = "myPassWouldBeHere"
FROM = USER
TO = ["******@gmail.com"]
SUBJECT = "Test"
MESSAGE = "Test"
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, MESSAGE)
try:
server = smtplib.SMTP()
server.connect(SERVER, PORT)
server.starttls()
server.login(USER,PASS)
server.sendmail(FROM, TO, message)
server.quit()
except Exception as e:
print e
print "\nCouldn't connect."
Run Code Online (Sandbox Code Playgroud)
我从键盘记录器获得了代码,但我清理了一下.我在这里读到了基本的SMTP如何工作,但很少有像starttls(方法)我不太了解的东西.
我真的很感激任何帮助.
因此,在我的pygame游戏中,我创建了一个对象列表,以便更新所有对象并更轻松地进行碰撞检查.所以当我进行碰撞检查时,我必须检查当前对象是否与我们碰撞检查的对象相同.这是我目前的代码:
def placeMeeting(self, object1, object2):
# Define positioning variables
object1Rect = pygame.Rect(object1.x, object1.y, object1.width, object1.height)
# Weather or not they collided
coll = False
# Loop through all walls to check for possible collision
for i in range(len(self.instances)):
# First check if it's the right object
if (self.instances[i] == object2):
print "yep"
object2Rect = pygame.Rect(self.instances[i].x, self.instances[i].y, self.instances[i].width, self.instances[i].height)
# Check for collision with current wall -- Horizontal
if (object1Rect.colliderect(object2Rect)):
coll = True
# Return the final collision result
return coll …Run Code Online (Sandbox Code Playgroud) 所以我有一个载满我游戏所有物体的载体; 玩家对象,敌人对象,墙壁等等......向量中的所有东西都是子对象Framework,所以我创建了向量类型,Framework因为这是它们与通用数据类型最接近的东西.
问题是它没有从它存储的对象运行重写的函数.所以我用谷歌搜索它,显然我通过将它们存储为对象切片Framework.那么我的问题是,如何将所有这些对象存储在一个列表中?
仅供参考,这是调用假定被覆盖的函数的地方.
for (vector<Framework>::iterator num = gameObjects.begin(); num != gameObjects.end(); ++num)
{
//The current thing
Framework currentObject = *num;
currentObject.frameEvent();
currentObject.frameEndEvent();
currentObject.drawEvent();
}
Run Code Online (Sandbox Code Playgroud)
提前致谢.