3 class ScanningTest : Window
5 text = "WIA Scanning Test";
6 background = activeBorder;
29 sprintf(s, "File://%08X", scannedImage);
30 imagePreview.image = { s };
33 imagePreview.image = null;
35 bmp = imagePreview.image.bitmap;
38 float ratio = (float)bmp.height / bmp.width;
39 if(ratio > 424.0f / 320.0f)
41 int w = 424 * bmp.width / bmp.height;
42 imagePreview.size = { w, 424 };
46 int h = 320 * bmp.height / bmp.width;
47 imagePreview.size = { 320, h };
55 scanner = GetScanner(true);
63 Picture imagePreview { this, text = "Image Preview", borderStyle = deep, size = { 320, 424 }, anchor = { right = 16, top = 16 } };
66 this, text = "Scan", size = { 60, 21 }, anchor = { bottom = 8 };
68 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
72 scanner = GetScanner(true);
73 if(scanner && (scanned = scanner.GetBitmaps()))
76 delete scannedImage; // Delete the previous image file if any
80 // Here 'i' is a Bitmap that we could just display ourselves, but we use a pseudo file so we can use the
81 // Picture control which works with a BitmapResource (which needs a file name)
83 scannedImage = TempFile { };
86 sprintf(s, "File://%08X", scannedImage); // 'File://' lets you use a File pointer as a file name
87 i.Save(s, "bmp", null);
89 // Take it out of the list because we free the other images (if any), but keep this one in 'scannedBitmap'
90 scanned.TakeOut(scannedBitmap);
104 ScanningTest mainForm {};