将图像以像素随机扫描生成布纹的条形码图形作为密码图发送。
接收到布纹的条形码图形后以原生成布纹码的随机路线像素扫描还原成原图像。以像素还原,
所以还原度极高。
现以VB-6编程代码介绍如下:
Dim Qw, Ph, W, H, Y(5000), X(5000), M, N As Integer, Q(5000), P(5000), L(100) As String
Private Sub Command1_Click()
Cls
Picture2.Picture = LoadPicture(App.Path + "\" + "原始图.jpg"): Picture1.Cls
Picture1.BorderStyle = 0: Picture2.BorderStyle = 0: Picture1.Cls
Picture1.Cls
Dim i, j, K, L As Integer
Dim c1 As Long
Dim r, g, b As Integer
Picture1.Width = 1600: Picture1.Height = 1600: Picture2.Width = 1600: Picture2.Height = 1600
' Picture1.Width = 1023: Picture1.Height = 689: Picture2.Width = 1023: Picture2.Height = 689
' Picture1.Width = 745: Picture1.Height = 449: Picture2.Width = 745: Picture2.Height = 449
' Form1.ScaleMode = 3
Picture1.ScaleMode = 3
Picture2.ScaleMode = 3
Qw = Timer: M = 0: W = Val(Text1.Text): H = Val(Text2.Text)
If W = o Or H = 0 Then W = 1600: H = 1600
For i = 1 To W: M = M + 1: N = 0 '这里的 I 要依据原始图像的分辨率来设置
L = Val(P(M))
For j = 1 To H: N = N + 1 '这里的 J 要依据原始图像的分辨率来设置
K = Val(Q(N))
c1 = Picture2.Point(i, j):
r = c1 And &HFF - 10
g = (c1 And 62580) / 256
b = (c1 And &HFF0000) / 65536
Picture1.PSet (L, K), RGB(r, g, b)
Next:
Next:
Ph = Timer: Print "用时 = "; (Ph - Qw) \ 1; "秒"
SavePicture Picture1.Image, "图像生成布码图.jpg"
End Sub
Private Sub Command2_Click()
Cls
Picture2.Picture = LoadPicture(App.Path + "\" + "图像生成布码图.jpg"): Picture1.Cls
Dim i, j, K, L As Integer
Dim c1 As Long
Dim r, g, b As Integer
Picture1.Width = 1600: Picture1.Height = 1600: Picture2.Width = 1600: Picture2.Height = 1600
' Form1.ScaleMode = 3
Picture1.ScaleMode = 3
Picture2.ScaleMode = 3
Qw = Timer:: M = 0: W = Val(Text1.Text): H = Val(Text2.Text)
If W = o Or H = 0 Then W = 1600: H = 1600
For i = 1 To W: M = M + 1: N = 0 'Picture2.Width
L = Val(P(i))
If P(M) = 1600 Then L = Val(P(M - 1))
For j = 1 To H: N = N + 1 'Picture2.Height
K = Val(Q(j))
If Q(N) = 1600 Then K = Val(Q(N - 1))
c1 = Picture2.Point(L, K)
r = c1 And &HFF
g = (c1 And 62580) / 256
b = (c1 And &HFF0000) / 65536:
'Print ,
Picture1.PSet (i, j), RGB(r, g, b)
Next
Next:
Ph = Timer: Print "用时 = "; (Ph - Qw) \ 1; "秒"
SavePicture Picture1.Image, "图像布码还原图.jpg"
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
Cls
Randomize
Picture1.BorderStyle = 0: Picture2.BorderStyle = 0
Picture1.Width = 1600: Picture1.Height = 1600: Picture2.Width = 1600: Picture2.Height = 1600
L(1) = " 573 5501365 578 667 7181515 167 582 526 627122810111600 320 202 734 1011015 324 544 545 461 4911741233 6581079 23 872 782 7841077 803 11110311236122513491407104010191552 844139210521245 685 6121585"
L(2) = " 306 326 414 9 7471060 440 38 73012981163 361 690 6381085 767 955 594 968 6731374 917 45412491343112314961539 226 818 97913891384 4211573 596 8161115 4901048 291418136015061182 399 189 3971339 918"
L(3) = " 863 82 7691175 551417 4291197 183 8501478 407 679 584 603 447 715 409 140 72411181003 4451130 341 808101414731562 395 889152811521160 391123713871172 208102914761302 626 950 187 5491151 4691361 533"
L(4) = " 175 81 967 394 161 213 69312501094 1141293 537 362 115 274 6391319 256 8191308 807 908 311 4911084 601 60 3561346 6471030 851 5681559 457 849 316 2871156 5031082 71212151421 761 371 152 741219 547"
L(5) = "1154 51 931 676 988 513 52 593 1961002142914301485 643 299 642 7831150 777 11 66415381519 78512901023 37613581186 957 862 382 153155615101059 4791513 8291128 19414121206 1811285 58815321243 379 450"
L(6) = " 8414681155 480 45 23113331345 59 764 10 92 683 69815871221 7321272 7 234 105 999 75811851093 9915901493 166 452 1191441 403 636 4851193 607 449 169 368 796 737 335 3781235 81412561166 828 88"
L(7) = " 54612821020 669 6281531 786 232 956 700 221491 6751050 8481460 920 651 34 4601363 241 687 31 258 317 138 841 919 43813261028 721 344 874 640 8421439 209 521 417 528 298 585 2431490 3121242 964 564"
L(8) = " 9611279 104 994 124 337 96 309 106 90414451313154012701144 2241583 14 691 24711191386 236 634 9512441104 478 280 228 7501525 353118810241320 128 171 943 654 20 719 468 83511051283 375132113251589"
L(9) = "1021 597 952 54013161482 3311399 852 211427 372 749 684 384107015531180 1701484 441 991 242 5291224 36 245 30 144 8901450 139 5521463 1791581 559 252 2831161 7091148 6951158 4101051 787 240 998 72"
L(10) = "11081129 9731401 981066 350 635 866 812 1541289 200144214471466 8146515971057 61012511332 174 692 270 263 516 165 131137 590 455 4861012 6821426 6321397 650 151 971 391355 34614921147 518 896 668"
L(11) = "14441314 7481433 474 493 598 499 729 586 771 451 775 12 377 10215161005 48 292 9391558 722 6051565 600 319 1081406 79515441522 832 563118312571106 286 558 6041364122311131268 878 91 870 456 753 347"
L(12) = " 143 87513901146 567 2591068 80 5351261 41 7311467 7601067138112321371 33310891474 5421227 70515491087137615241315 239 47314031277 672 902 595 1451025 470 976 43412111362 914 883124110981454 515 42"
L(13) = " 8311456 1101263 90012811234 392 2051523 61 871 4621284 959 365 50714981372 910 160 197 570 448 9031171 972 857 401477 905 5021571 680 304 726 220 571 623 31011431018 985129414941204 3831570 255 960"
L(14) = " 565 300 534 619 708 29612881033129514711275 465122213051157 975 57 566 498 4671348 336 779 323 471144810621507 839 9401229 8514461078 97010651112130414891352 811 3871543 983 817 122 523 244 415 266"
L(15) = " 195 6601307 89711391125 21115541398 173 155 3661530 948 28815931517 2061312 6371529 511 853 744 483 531 492 477 6711259 2351486 9711111246 864 5541296 932 707 909 1881042 7351239 771329 345 901331"
L(16) = " 7201388 969 713 3221574 135 2191400 257 385 422 93515611073 616 990 671306 982 2271459 717 370 349 406 8431514 65 916 443 790 5571271 184 1801599 806 508 539 836 77815451092 3481269 359108614811212"
L(17) = "15201596 2751300 556119014151586 423 947 6611393 652 15 64 606 820 431 6461286 888108112661369 98011621414 958 237 543 177 94 697 476 290 802 906 7721341 688 246 260 861 754 355 766 432 3431379 262"
L(18) = " 743 2141356 36311961404 400 2851402 801 107 420 809 6171192 759 8731509 9151049 294 615 522 757 885 699 156 694 2761103 1411551 241075 659 644 4941505 367 7615691126 2721367 686 56115801195 826 645"
L(19) = "1088 3931203 56 44 3571273 2171209 792 435 10013501216 176 327 5011340 8801425118712781173 488 63314231431 497 364 663 313 303 7041207 846 178 82513511410 131 77614611132 813 2651385 402 3211037 799"
L(20) = " 8610441069 6701117 621 57511981055 78 63113471041 26814641262 157 216 30112381380 500 4 401 380 351475 186 752 9271004 332 89511701009103411071141 7911542 1331449 926 1211521 608 222153513181495"
L(21) = "1054 3421582 54 360 5251230 147 884 7111299 74210761416 954 495 62 1851280 5241422 12015181488 1681226 75100813011480 466 587 741 893 6241502 1591503 834159515601006 14813771512 1321121 426 781 804"
L(22) = "158410161131 945 657 1251337 1131220 928 163 9841303 656 762 4641167 739 172132210991566 8271526 20414991344 551 733 463 436 446 577 19 630 755 886 8910461534 924 824 19911641142 701274 1361435 913"
L(23) = "1127 930 88713091072 314 150 1641504 6771511 756 691382 995 328 43711201267 891 822 653 33 674 112 254 8941487 798 625139415761359 482109513111443 877 352 4891550 5 1261462 318 520 3731260 823 198"
L(24) = "15721479 54115461258 738 620 8821074 805 8401116 9921411 4111177 774 589 727 484 614 3301578 962 8151178 993 765 8211424 2251592 881 229 845 192 76310831176 49610451159 953 94211841501 7701091 965 444"
L(25) = "1373 8471189 860 514 412 5761264 1621255 32 233 267 9861017 929 898 307 461366 532 18214531563 892 20115791338 869 856 7251291 562 989 3581058 4591436108013361061 8312871252150811451043 4051063 666"
L(26) = "11491575 43 453 203 458 855 2611090 751 2511469100114971557113415771452 390 191 1931038 71410351533 71 519 354 2711026 907 60915481231120114321483 3881168 442 2121109114012001457 334 899 868 951 416"
L(27) = " 696 581 2771124 339 934109614051470 996 6621458 879 5551555 129 2971247 2791102 701 58 210 8371217 273 1231292 215 599 1171110 7021324 9311331342 251383 7061353 1421100 37412761335 4191370 9461330"
L(28) = "1434 901 9411194 487 3291181 731254 936 238 7891039 430 661165 997 3 591 921 2715001437 418 512158813571000 305 6291428 472 978 28 6551240 47 618 538 439 548 116 3021420 425 689 134 5921064 876"
L(29) = " 103 1 282 938 253 793 859 583 810 3981053 867 9251327 2781208 1271536 87 3891368 602 865 7231199 325 70315641537 974 386 481 966 207 340 149 230 264 4281007 506140912531310 5691472 987 190 949 681"
L(30) = " 308 293 641 1371375 678 269 109 295 50911791191 574 72815981135 218 158145113341213 794 981 7461010 284 26 505 5601440 4041455 649 7681101 3961541 50 16 710 63 963 351 854 580 28910221323 933 536"
L(31) = " 530 4241567 7971214 736 381 71610131594 51711221071 648 21047 833 37 2911378 8581218 42711531248 504 66515271265 9441205 923 937 527 18 922 912 53 6 74510561210 223 171396 611 250 79 68 118"
L(32) = "1391 83814191354 413129710271202 613 3691408 146 8301568 977113610321591 8001317113814381413 408 622 572 773 510 433 788 130 249 475 3151036 28111691328 338 579 911 780 2481395 55311141097 2211547 740"
L(34) = " 7641371 319 2671548 63213041413 6041181 503 77 23914001275 276 499 5110321474 693 1641321 962 161 8961596 287 540 299 5691022 9691107 257 819 594 7861165 263 960 7951412 696134114161057 842 862 174"
L(35) = " 421 2351024 265 4171440 630 181 691482 7091333 8431266 242 80 1671006 9471358 850 5021459 302 874 8091250 640 475 190 813 340 269 49 7081036 631 1312691595 636 152 787 4361127 42 6331149 232 992"
L(36) = " 179 519 498 670 123 952 406 9261415 898 704 181380152812371447 31215301130 869 334 599 530 454 62513871576 283 639 39 339104112241310 650 9381047 496112010371423 958 1711375 441455 69412591017 484"
L(37) = "13611599 452 293 697 79810871426 141 425 635 690 369 895 1311481 5561056108810971049 3521267 3541102 727 543 12413941442 43111661355 7031141 94 889 246 919137215231243 26613451560 601446 943 48 652"
L(38) = " 9851046 782 520 3651556 5011217 7111600 7221489 6921271 72 754 148 3471311 435 914 6231156 879 471307 286 374 672 4331483 31 7911597 225 707 4641082 258 739 371 145 714 102 118 780 379 536 702 987"
L(39) = " 881 85810501200 71 9971503 829 219 6421095 474 30 5841045 4631238 931 9713621574 361184 101 671 863 867 453 712 802 561 74114221349 130 805 822 948 335 381 324 147 4241058 658 458 7571462 440 129"
L(40) = " 2921216 10315641514 56314171552 3931062 32811971287 261487 770 222 471117314791421 84 932 578 968 111 447 441 155 2231091 773 767 368 525 450 106154215171040 826 30312681289 3781151 6131186 893 993"
L(41) = " 534 2851009 81012271299 587 112 870 4931034 2841010 115 30714491485142914941521 554 101472 298 483 641 330 268 142 27915931198 405 612 766 8681221 8851225 915 414 908 753 7321352 524140911441313 555"
L(42) = " 6771066 3411090 221 991 4891418 380 924 561070 698 107 899 570131712941410 82014841506 7621577 840 495 593 215 6991071 759 807 93515221508 18313561343 78107713991396 86 504138115011194105310861467"
L(43) = " 3501527 660 911113813201364 88 8511228 403 8661303 448 26410081140 163 59011211591 288 974 7251172 66212531582 2561154 8001031 153 432 961117414341452130115471332 706 3511579 501378 308 2781585 309"
L(44) = "13061109 812 8901568 201 647 120 9331448 140 52811551339 89 638 500 7191439 676 220 680 9771385 348 273 3671561 6551240 984 3251256106112461150 210 617128110521565 799 241118912261567 686 6 1821152"
L(45) = "142412311134 46714581187 883 291 4921096 360 912 92813531425 507 24311771370 5091495 567 860 856 336 281 416 396 426 5151218 478 911080 4131326 995117514881460 629 71068 199 620 2091588 651539 605"
L(46) = " 13513481515120814081505 560 275 4091164 8721477 418 211437 806 8771129 1581500137415371026 674 53 740 461389 9701229 618 65711951557 7521544 184 151 361 234152910591509 3 4561283 736 4651261 146"
L(47) = "1069 950 729 679 6891055 481127011191205 615 191 743 3421543 603 513 9251257 34515021302 790 36410271188 16 942 768 9801491 83159015461236 192154513541251 79 99415531101 7331443 58011691014 921 797"
L(48) = " 274 581397 305 281118 761 717 608 1981180 934 816 562 986 315 399 917 205 7001005 290 3981124 961534 216 383 585 6661461 2001044 1081475 395 73 29 6871133 358 479 9791296 669 941 857 15 920 404"
L(49) = " 43712631110 9515201185 929 472 9591316 227 117 783 28011451232155913121431 355 710 967 930 738 626 3861199 589 7811319 742 6811563 318 237 716 991583 876 251196 1271100 7781454 194 372 3413881360"
L(50) = " 8541019 159 878 545 644 763 9541519 180 526 884 871 6001558 212 327 457 5391171132815261072 104 54 326 983 93 616 58812931213 547 550 90312641390 240 775 7241329 922 741023 233 156 685 815 575 746"
L(51) = "1363 6651490 1141435148015781433 73110481241 548 468 388 105 4 332 5511157 422 149 423 774 901219 9001351 8241279 518 4551030 5981532 51108 522 23814781510 11911471103 9661201 801 750 69513691182"
L(52) = "100412721569 971 2361206 89714861334 4001043 2511235 162 8591248114814381367 581 8821308 6113861242 138 834 57614191379 6211190 366 963 715 82 13311531012 97815501018 861 7231016 1501427 144 204 294"
L(53) = "1298 793 4071210 832 377 1691407 614 2771512 936 252 189 24 391 851492 904 946 259 785 2891580 951 196 940 972 57 4011015 16514511223 32 187 47613051158 397 6841398 81011 9011167 113 370 760 622"
L(54) = " 186 579 965 6071038 226 3111391 675 888 67 271 906 597 449 542 756 172 999 582 506 154 5212601092 6831555 248 744137312901450 62710601366 343 7691376 855 91014661076 136 853 37315981179 301 565 789"
L(55) = "15701063 429 601 6611168 5531342 902 195 5771209 490 619 3201136 849 25411591000 982 394 19 667 927 201160 322 735 313 57310651113 949 59215241414 8641359 6481265 323 538 392 30415721025 953 382 359"
L(56) = "1278 22 3901384 415 516 98913371203 527 512 362 5831504 7771562 7261444 656 168 37 549 83112821083 466 37615311021 92 12611431324 4911131 157 7961146 6491094 451 631327 784 260 758 552 894 411 751"
L(57) = " 6371428 185 4881587 363 8181035 420 8391496 247 609 905 8331274 4281111 668 412 653 410 41100311931075 497 66 923 535 5951162 206 6731513 203 7491115 317 29615731511 171254 803 121084 9811445 794"
L(58) = " 511 2551463 646 494 43 510 480 62412451028 245 46214041099120411051456 2821013 823 70 3331285 23 957 4191464 17515751122 841 57215071249 45 788 5461314 730 473 574 88011141033 5711322 139 981288"
L(59) = "121413501516 643 916 610 262 387 249 434 5171007 2291170 645 6811171473 329 338 84611251137 9561085 272 514 1321280134614981132 688 35 845 737 771 508 7051432 211 748 4461571 59114031315 218 745 487"
L(60) = " 66410811541 887 557 537 214 529127315381406 12812391457106712861533 3141252 1221220 445 663 532 682 82710421581 602 973 91811911365 659 81412111230 544 8381336 93912951178 541 844 8371554 46115511392"
L(61) = "1291 310 2301586 337 38 909 170 891 691 82110391499 634 344 558 955147014011020 568 964 270 8251002 76 81112021255 224 207 3061549 988 65111161161 5861344 873 976 408 875 1731430 734 253 17715361054"
L(62) = "1383 1431176 442 20213351584 811207119213181292110610291284 606 176 848 116 10912621420 349 188 678 3311395 31614971074 427 1371594106413231525 375 197 621325 55 4591247 3851215 208 7131233 300 486"
L(63) = " 40 5641163 779 835 2441139 998 357 521 747 9451589 865 261 439 7510511258 2 559 937 975 166 533 4381126 27 217 460 808 8041465 1341471 111183 5961518 523 295 213 228 121 485111210731436 87 728"
L(64) = "1468 84714051411 76511421276 443 4701135 125 701 1601104 907 33 830 5912121535 990129714761338 402 356 77213931331 14 4771098 346 1001079 817145310781347 721 384 469 792 94415921441 430 836 482 321"
L(65) = " 996 628 5051382 755 64 9 4441469 110 8521368 7761340 17812341357 389 61112221244 828 531 353 19310891300140215401093 231 7181123 7201377 6541309 91314931566 1 29713301001 5661277 250 892 8861128"
K = 0
For i = 1 To 32
For j = 0 To 49: K = K + 1
P(K) = Mid(L(i), (j) * 4 + 1, 4)
Next j, i: K = 0
For i = 34 To 65: For j = 0 To 49: K = K + 1
Q(K) = Mid(L(i), (j) * 4 + 1, 4)
Next j, i: K = 0
' Print Picture1.Width, Picture1.Height, P(743), P(744), P(746),
End Sub
---------------------------------------------------------
《图像1600X1600像素布纹码》程序运行说明:
一 生成像素布纹码图像:
⒈ 将要生成布码的图件缩放成分辨率小于1600X1600 像素大小后存放于此运行文件的
同一文件夹内, 并将其文件名修改为“原始图.jpg”;
⒉ 运行"图像布码生成"文件,将自动生成“图像生成布码图.jpg”
并保存在同一文件夹内;
⒊ 这个“图像生成布码图.jpg”就是要发送的“密码图”。到此,密码图制作完成。
二 还原像素布纹码图像:
⒈ 将接收到的“图像生成布码图.jpg”放于此运行文件的同一文件夹内,并将其文件名修
改为“图像生成布码图.jpg”;
⒉ 运行“图像布码还原”文件,将自动生成“图像布码还原图.jpg”
并保存在同一文件夹内;
⒊ 这个“布码复原图.jpg”就是原始图件的按像素完全复原图。
三 温馨提示:
1. 运行后所生成的文件都是临时文件,需要及时修改文件名,否则再运行时会被覆盖。
2. 开始运行时先要将原始图的分辨率输入到程序的文本框中,否则将按1600X1600分辨率运行,影响速度。
3. 先运行生成程序后运行还原程序。因为运行还原程序时需要有“图像生成布码图.jpg”。
========================================
说明:这里是原始代码,还必须配以窗体设计:在窗体上设置两个命令按钮;两个图片框。
这是最基本的配置。
联系客服