home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / VBasic / STRBMP.ZIP / TEST.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-09-22  |  8.9 KB  |  281 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00FF0000&
  4.    Caption         =   "STR2BMP.DLL Demonstration"
  5.    ClientHeight    =   4605
  6.    ClientLeft      =   1860
  7.    ClientTop       =   2190
  8.    ClientWidth     =   7245
  9.    ClipControls    =   0   'False
  10.    Height          =   5040
  11.    Left            =   1785
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   4605
  14.    ScaleWidth      =   7245
  15.    Top             =   1830
  16.    Width           =   7395
  17.    Begin CommandButton CommandForceError 
  18.       Caption         =   "Force error"
  19.       Height          =   555
  20.       Left            =   5040
  21.       TabIndex        =   13
  22.       Top             =   3780
  23.       Width           =   2055
  24.    End
  25.    Begin CommandButton CommandCopyResultToB 
  26.       Caption         =   "Copy RESULT to B"
  27.       Height          =   555
  28.       Left            =   5040
  29.       TabIndex        =   12
  30.       Top             =   1380
  31.       Width           =   2055
  32.    End
  33.    Begin CommandButton CommandAnd 
  34.       Caption         =   "RESULT = A AND B"
  35.       Height          =   555
  36.       Left            =   5040
  37.       TabIndex        =   11
  38.       Top             =   780
  39.       Width           =   2055
  40.    End
  41.    Begin PictureBox PictureResult 
  42.       AutoRedraw      =   -1  'True
  43.       BorderStyle     =   0  'None
  44.       Height          =   615
  45.       Left            =   3240
  46.       ScaleHeight     =   41
  47.       ScaleMode       =   3  'Pixel
  48.       ScaleWidth      =   81
  49.       TabIndex        =   7
  50.       Top             =   2820
  51.       Width           =   1215
  52.    End
  53.    Begin CommandButton CommandOr 
  54.       Caption         =   "RESULT = A OR B"
  55.       Height          =   555
  56.       Left            =   5040
  57.       TabIndex        =   6
  58.       Top             =   180
  59.       Width           =   2055
  60.    End
  61.    Begin CommandButton CommandInvertA 
  62.       Caption         =   "Invert A"
  63.       Height          =   555
  64.       Left            =   5040
  65.       TabIndex        =   5
  66.       Top             =   3180
  67.       Width           =   2055
  68.    End
  69.    Begin CommandButton CommandCompareAtoB 
  70.       Caption         =   "Compare A to B"
  71.       Height          =   555
  72.       Left            =   5040
  73.       TabIndex        =   4
  74.       Top             =   2580
  75.       Width           =   2055
  76.    End
  77.    Begin PictureBox PictureA 
  78.       AutoRedraw      =   -1  'True
  79.       BorderStyle     =   0  'None
  80.       Height          =   615
  81.       Left            =   360
  82.       ScaleHeight     =   41
  83.       ScaleMode       =   3  'Pixel
  84.       ScaleWidth      =   81
  85.       TabIndex        =   3
  86.       Top             =   2820
  87.       Width           =   1215
  88.    End
  89.    Begin PictureBox PictureB 
  90.       AutoRedraw      =   -1  'True
  91.       BorderStyle     =   0  'None
  92.       Height          =   615
  93.       Left            =   1800
  94.       ScaleHeight     =   41
  95.       ScaleMode       =   3  'Pixel
  96.       ScaleWidth      =   81
  97.       TabIndex        =   2
  98.       Top             =   2820
  99.       Width           =   1215
  100.    End
  101.    Begin CommandButton CommandCopyAtoB 
  102.       Caption         =   "Copy A to B"
  103.       Height          =   555
  104.       Left            =   5040
  105.       TabIndex        =   1
  106.       Top             =   1980
  107.       Width           =   2055
  108.    End
  109.    Begin CommandButton CommandDrawCircle 
  110.       Caption         =   "Draw Circles in A"
  111.       Height          =   555
  112.       Left            =   600
  113.       TabIndex        =   0
  114.       Tag             =   "Write line to A"
  115.       Top             =   600
  116.       Width           =   3495
  117.    End
  118.    Begin Label Label3 
  119.       BackColor       =   &H00FF0000&
  120.       Caption         =   "A"
  121.       FontBold        =   -1  'True
  122.       FontItalic      =   0   'False
  123.       FontName        =   "MS Sans Serif"
  124.       FontSize        =   12
  125.       FontStrikethru  =   0   'False
  126.       FontUnderline   =   0   'False
  127.       ForeColor       =   &H00FFFFFF&
  128.       Height          =   255
  129.       Left            =   840
  130.       TabIndex        =   10
  131.       Top             =   3540
  132.       Width           =   255
  133.    End
  134.    Begin Label Label2 
  135.       BackColor       =   &H00FF0000&
  136.       Caption         =   "B"
  137.       FontBold        =   -1  'True
  138.       FontItalic      =   0   'False
  139.       FontName        =   "MS Sans Serif"
  140.       FontSize        =   12
  141.       FontStrikethru  =   0   'False
  142.       FontUnderline   =   0   'False
  143.       ForeColor       =   &H00FFFFFF&
  144.       Height          =   255
  145.       Left            =   2280
  146.       TabIndex        =   9
  147.       Top             =   3600
  148.       Width           =   255
  149.    End
  150.    Begin Label Label1 
  151.       BackColor       =   &H00FF0000&
  152.       Caption         =   "Result"
  153.       FontBold        =   -1  'True
  154.       FontItalic      =   0   'False
  155.       FontName        =   "MS Sans Serif"
  156.       FontSize        =   12
  157.       FontStrikethru  =   0   'False
  158.       FontUnderline   =   0   'False
  159.       ForeColor       =   &H00FFFFFF&
  160.       Height          =   255
  161.       Left            =   3480
  162.       TabIndex        =   8
  163.       Top             =   3540
  164.       Width           =   855
  165.    End
  166. '// Test.frm : VB Demo for STR2BMP.DLL.
  167. '//   Freeware -- Version 1.1   09/20/93
  168. '//   Written by Jorge Monasterio (CIS 72147, 2674)
  169. Option Explicit
  170. ' Strings to hold pixel information.
  171. Dim a$
  172. Dim b$
  173. Dim result$
  174. Sub CommandAnd_Click ()
  175.   Dim ret&
  176.   If (BMP_GetSize(PictureA.Image) = 0) Then
  177.      MsgBox ("Bitmap too large to store!")
  178.      End
  179.   End If
  180.   a$ = BMPToString(PictureA.hDC, PictureA.Image)
  181.   b$ = BMPToString(PictureB.hDC, PictureB.Image)
  182.   result$ = StringBMP_and(a$, b$)
  183.   ret& = StringToBmp(result$, PictureResult.hDC, PictureResult.Image)
  184.   PictureResult.Refresh
  185. End Sub
  186. Sub CommandCompareAtoB_Click ()
  187.   Dim bytes As Long
  188.   Dim a$, b$
  189.   Dim ret&
  190.   bytes = BMP_GetSize(PictureA.Image)
  191.   If (bytes = 0) Then
  192.      MsgBox ("Bitmap too large to store!")
  193.      End
  194.   End If
  195.   a$ = BMPToString(PictureA.hDC, PictureA.Image)
  196.   If BMP_GetSize(PictureB.Image) <> bytes Then
  197.      MsgBox "Bitmaps must be same size to compare. "
  198.      End
  199.   End If
  200.   b$ = BMPToString(PictureB.hDC, PictureB.Image)
  201.   bytes = StringBMP_Compare(a$, b$)
  202.   MsgBox "This difference is " + Str$(bytes) + " pixels."
  203. End Sub
  204. Sub CommandCopyAtoB_Click ()
  205.   Dim ret&
  206.   b$ = a$
  207.   ' Fill PictureBox with information in B$
  208.   ret& = StringToBmp(b$, PictureB.hDC, PictureB.Image)
  209.   ' Display the new information
  210.    PictureB.Refresh
  211. End Sub
  212. Sub CommandCopyResultToB_Click ()
  213.   Dim ret&
  214.   ' Copy RESULT to B (STRINGS!)
  215.   b$ = result$
  216.   ' Convert the new B$ to a picture and display it!
  217.   ret& = StringToBmp(b$, PictureB.hDC, PictureB.Image)
  218.   PictureB.Refresh
  219. End Sub
  220. Sub CommandDrawCircle_Click ()
  221.   Dim ret As Long
  222.   Dim bytes As Long
  223.   ' Draw a black circle
  224.   PictureA.FillStyle = 0
  225.   PictureA.FillColor = RGB(0, 0, 0)
  226.   PictureA.Circle (10, 10), 5, RGB(0, 0, 0)
  227.   PictureA.FillColor = RGB(255, 0, 0)
  228.   PictureA.Circle (40, 25), 5, RGB(255, 0, 0)
  229.   PictureA.FillColor = RGB(0, 255, 0)
  230.   PictureA.Circle (25, 30), 5, RGB(0, 255, 0)
  231.   ' Determine the size of a string required to hold PictureA
  232.   bytes = BMP_GetSize(PictureA.Image)
  233.   If (bytes = 0) Then
  234.      MsgBox ("Bitmap too large to store as a string!")
  235.      Stop
  236.   End If
  237. ' Convert PictureA into A$
  238.   a$ = BMPToString(PictureA.hDC, PictureA.Image)
  239. End Sub
  240. Sub CommandForceError_Click ()
  241.   Dim bytes&
  242.   bytes = BMP_GetSize(Me.Image)
  243.   If (bytes = 0) Then
  244.      MsgBox ("Bitmap too large to store as a string! After clicking OK, the next thing you will see is a runtime error.")
  245.   End If
  246.   ' Create a string containing the bitmap for this whole form.
  247.   '  Too large to fit. FORCES RUNTIME ERROR.
  248.   a$ = BMPToString(Me.hDC, Me.Image)
  249. End Sub
  250. Sub CommandInvertA_Click ()
  251.   Dim bytes As Long
  252.   Dim ret&
  253.   ' Copy PictureA into A$
  254.   a$ = BMPToString(PictureA.hDC, PictureA.Image)
  255.   ' Invert A$ and store the result in RESULT$
  256.   a$ = StringBMP_Invert(a$)
  257.   ' Convert A$ into a picture box and display.
  258.   ret& = StringToBmp(a$, PictureA.hDC, PictureA.Image)
  259.   PictureA.Refresh
  260. End Sub
  261. Sub CommandOr_Click ()
  262.   Dim bytes As Long
  263.   Dim ret&
  264.   ' Make sure strings are correct size to hold bitmap info.
  265.   '  The following code works only if all three bitmaps are the
  266.   '  same size.
  267.   bytes = BMP_GetSize(PictureA.Image)
  268.   If (bytes = 0) Then
  269.      MsgBox ("Bitmap too large to store!")
  270.      End
  271.   End If
  272.   ' Fill A$ and B$ with the bitmaps in PictureA and PicutreB, respectively.
  273.   a$ = BMPToString(PictureA.hDC, PictureA.Image)
  274.   b$ = BMPToString(PictureB.hDC, PictureB.Image)
  275.   ' Or the pixels in A$ with those in B$ to create RESULT$
  276.   result$ = StringBMP_Or(a$, b$)
  277.   ' Convert the RESULT$ into a picture box and display it.
  278.   ret& = StringToBmp(result$, PictureResult.hDC, PictureResult.Image)
  279.   PictureResult.Refresh
  280. End Sub
  281.