{"id":108,"date":"2006-12-09T12:09:28","date_gmt":"2006-12-09T04:09:28","guid":{"rendered":"http:\/\/tmp.xujiwei.com\/blog\/?p=108"},"modified":"2010-01-29T12:36:10","modified_gmt":"2010-01-29T04:36:10","slug":"thumbnail-in-vb-by-picturebox","status":"publish","type":"post","link":"https:\/\/xujiwei.com\/blog\/2006\/12\/thumbnail-in-vb-by-picturebox\/","title":{"rendered":"\u5728VB\u4e2d\u7528PictureBox\u5b9e\u73b0\u56fe\u7247\u7684\u7f29\u7565\u56fe\u6d4f\u89c8"},"content":{"rendered":"<p>\u8981\u5199\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u6d89\u53ca\u5230\u7f29\u7565\u56fe\u7684\u95ee\u9898\uff0c\u539f\u5148\u51c6\u5907\u7528StretchBlt\u6765\u5b9e\u73b0\u7684\uff0c\u540e\u6765\u627e\u4e86\u4e0b\u53d1\u73b0PictureBox\u7684PaintPicture\u65b9\u6cd5 \u4e5f\u53ef\u4ee5\u628a\u56fe\u50cf\u6309\u89c4\u5b9a\u5927\u5c0f\u8fdb\u884c\u7f29\u653e\uff0c\u8bd5\u4e86\u4e00\u4e0b\u611f\u89c9PaintPicture\u7684\u901f\u5ea6\u6bd4StretchBlt\u5feb\u4e00\u4e9b\u3002<\/p>\n<p>PaintPicture\u7684 \u51fd\u6570\u5b9a\u4e49\u4e3a\uff1a<\/p>\n<p>Sub\u00a0PaintPicture(Picture\u00a0As\u00a0IPictureDisp,\u00a0X1\u00a0As\u00a0Single,\u00a0Y1\u00a0As\u00a0Single,\u00a0[Width1],\u00a0[Height1],\u00a0[X2],\u00a0[Y2],\u00a0[Width2],\u00a0[Height2],\u00a0[Opcode])<\/p>\n<p>X1 \u548cY1\u662f\u76ee\u6807\u4f4d\u7f6e\uff0cWidth1\u548cHeight1\u662f\u76ee\u6807\u5927\u5c0f\uff0c\u9ed8\u8ba4\u662fPictureBox\u7684\u5927\u5c0f\uff0cX2\u548cY2\u662f\u6e90\u4f4d\u7f6e\uff0cWidth2\u548cHeight2\u662f\u6e90 \u5927\u5c0f\uff0cOpcode\u662f\u64cd\u4f5c\u65b9\u5f0f\uff0c\u9ed8\u8ba4\u5e94\u8be5\u662fvbSrcCopy\uff0c\u5982\u679cWidth1\u3001Height1\u548cWidth2\u3001Height2\u7684\u5927\u5c0f\u4e0d\u4e00\u6837\u5219\u8fdb\u884c\u7f29 \u653e\u3002<\/p>\n<p>\u65b0\u5efa\u4e00\u4e2a\u5de5\u7a0b\uff0c\u8bbe\u7f6eForm1\u7684ScaleMode\u4e3a\u201c3\u00a0-\u00a0Pixel\u201d\uff0c\u5f80\u7a97\u4f53\u4e0a\u653e1\u4e2aFileListBox\u63a7\u4ef6\u540d\u79f0\u4e3a File1\uff0c1\u4e2aImageList\u63a7\u4ef6\u540d\u79f0\u4e3aImageList1\uff0c2\u4e2aPictureBox\u63a7\u4ef6\uff0c\u4e00\u4e2a\u540d\u79f0\u4e3aPicture1\uff0cAutoResize \u4e3aTrue\uff0cVisible\u4e3aFalse\uff0c\u53e6\u5916\u4e00\u4e2a\u540d\u79f0\u4e3aPicture2\uff0cAutoRedraw\u4e3aTrue\uff0cVisible\u4e3aFalse\uff0cWidth\u548c Height\u4e3a128\uff0c1\u4e2aListView\u63a7\u4ef6\u540d\u79f0\u4e3aListView1\uff0c\u5c06\u56fe\u50cf\u5217\u8868\u4e2d\u666e\u901a\u8bbe\u7f6e\u4e3aImageList1\u3002<\/p>\n<p>\u5728\u7a97\u4f53\u91cc\u6dfb\u52a0\u5982 \u4e0b\u4ee3\u7801\uff1a<\/p>\n<blockquote>\n<div id=\"_mcePaste\">\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\">' \u7a97\u4f53\u8f7d\u5165\u65f6\u8f7d\u5165\u56fe\u50cf\u5217\u8868<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\">Private Sub Form_Load()<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> Dim i As Long<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> For i = 0 To File1.ListCount - 1<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> ' \u8f7d\u5165\u56fe\u50cf<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> Picture1.Picture = LoadPicture(File1.Path &amp; \"\\\" &amp; File1.List(i))<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> ' \u751f\u6210\u7f29\u7565\u56fe<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> Picture2.PaintPicture Picture1.Picture, 0, 0<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> ' \u6dfb\u52a0\u7f29\u7565\u56fe\u5230ImageList<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> ImageList1.ListImages.Add , , Picture2.Image<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> ' \u6dfb\u52a0\u7f29\u7565\u56fe\u5230ListView<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> ListView1.ListItems.Add , , File1.List(i), i + 1<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> DoEvents<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> Next<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\">End Sub<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\">' \u7a97\u4f53\u6539\u53d8\u5927\u5c0f\u65f6\u6539\u53d8ListView\u7684\u5927\u5c0f<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\">Private Sub Form_Resize()<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> With ListView1<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> .Top = 0<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> .Left = 0<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> .Width = Me.ScaleWidth<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> .Height = Me.ScaleHeight<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"font-style: normal;\"> End With<\/span><\/div>\n<div><span style=\"font-style: normal;\"><span style=\"color: #4e4e4e;\">End Sub<\/span><\/span><\/div>\n<\/div>\n<\/blockquote>\n<div><span style=\"font-style: normal;\">\u8fd9\u6837\u5c31\u5dee\u4e0d\u591a\u53ef\u4ee5\u5b9e\u73b0\u56fe\u7247\u7684\u7f29\u7565\u56fe\u6d4f\u89c8\u4e86\u3002<\/span><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u5199\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u6d89\u53ca\u5230\u7f29\u7565\u56fe\u7684\u95ee\u9898\uff0c\u539f\u5148\u51c6\u5907\u7528StretchBlt\u6765\u5b9e\u73b0\u7684\uff0c\u540e\u6765\u627e &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/xujiwei.com\/blog\/2006\/12\/thumbnail-in-vb-by-picturebox\/\">\u7ee7\u7eed\u9605\u8bfb &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[77,78,76],"_links":{"self":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts\/108"}],"collection":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":0,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/posts\/108\/revisions"}],"wp:attachment":[{"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/categories?post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xujiwei.com\/blog\/wp-json\/wp\/v2\/tags?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}