Академический Документы
Профессиональный Документы
Культура Документы
1.1 EXISTING SYSTEM The existing system of traditional image storage consists of file organizations and manual search and retrieval.
NECESSITY OF IMAGE COMPRESSION The figures in table show how the qualitative transition from simple text to full-motion video data and the disk space,
Bits/pixels Or Bits/sample
A page of text Telepho ne Quality Speech Grayscal e Image Color Image Medical Image SHD Image Fullmotion Video
11*8.5 10sec
512*512
8bpp
262KB
2.1Mb/ima ge
transmission bandwidth, and transmission time needed to store and transmit such uncompressed data.
Table Multimedia data types and uncompressed storage space, transmission bandwidth, and transmission time required .The prefix kilo-denotes a factor of 1000 rather than 1024. The examples clearly illustrate the need for sufficient storage space, large transmission bandwidth, and long transmission time for image, audio, and video data. At the present state of technology, the only solution is to compress multimedia data before its storage and transmission, and decompress it at the receiver for play back. For example, with a compression ratio of 32:1, the space bandwidth, and transmission time requirements can be reduced by a factor of 32, with acceptable quality. 1.3 Proposed System
2. SYSTEM SPECIFICATION
Framework 1.1. This also answers why should I use Visual Basic .NET, what can I do with it?
Simplified Deployment
With Visual Basic .NET we can build applications more rapidly and deploy and maintain them with efficiency. Visual Basic .NET 2003 and .NET Framework 1.1 makes "DLL Hell" a thing of the past. Side-by-side versioning enables multiple
A Tool for Using MS Access as a Multimedia Database 5
versions of the same component to live safely on the same machine so that applications can use a specific version of a component. XCOPY-deployment and Web auto-download of Windows-based applications combine the simplicity of Web page deployment and maintenance with the power of rich, responsive Windows-based applications.
Improved Coding
You can code faster and more effectively. A multitude of enhancements to the code editor, including enhanced IntelliSense, smart listing of code for greater readability and a background compiler for real-time notification of syntax errors transforms into a rapid application development (RAD) coding machine.
Mobile Applications
Visual Basic .NET 2003 and the .NET Framework 1.1 offer integrated support for developing mobile Web applications for more than 200 Internet-enabled mobile devices. These new features give developers a single, mobile Web interface and programming model to support a broad range of Web devices, including WML 1.1 for WAPenabled cellular phones, compact HTML (cHTML) for i-Mode phones, and HTML for Pocket PC, handheld devices, and pagers. Please note, Pocket PC programming is not available in Visual Basic .NET Standard, it requires Visual Studio 2003 Professional, or higher.
COM Interoperability
You can maintain your existing code without the need to recode. COM interoperability enables you to leverage your existing code assets and offers seamless bi-directional communication between Visual Basic 6.0 and Visual Basic .NET applications.
You can reuse all your existing ActiveX Controls. Windows Forms in Visual Basic .NET 2003 provide a robust container for existing ActiveX controls. In addition, full support for existing ADO code and data binding enable a smooth transition to Visual Basic .NET 2003.
Upgrade Wizard
You upgrade your code to receive all of the benefits of Visual Basic .NET 2003. The Visual Basic .NET Upgrade Wizard, available in Visual Basic .NET 2003 Standard Edition, and higher, upgrades up to 95 percent of existing Visual Basic code and forms to VB .NET with new support for Web classes and User Controls.
The language of C
C has now become a widely used professional language for various reasons It has high-level constructs It can handle low-level activities It produces efficient programs. It can be compiled on a variety of computers. The various characteristic of C are Small size Extensive use of function calls
A Tool for Using MS Access as a Multimedia Database 9
Loose typing unlike PASCAL Structured language Low level (Bitwise) programming readily available Pointer implementation-extensive use of pointers for memory, array, structures and functions.
Complier-based
In the first place, it is a complier based language. This on one hand means that all grammatical errors must be out of the program before it will do anything .it also means that it does exactly the same outside the developing environment as it does inside once you have got it running.
The Advantages of C
The good news about C is that we can write code which runs quickly, and our program is very close to the hardware .It means that we can access low level facilities in our computer
A Tool for Using MS Access as a Multimedia Database 10
quite easily ,without the complier or run time system stopping you from doing something potentially dangerous . The use of complier directives to the pre-processor makes it possible to produce a single version of a program which can be complied on several different types of computer. In this sense C is said to be very portable. The function libraries are standard for all versions of C so they can be used on all systems.
Programming in C or Assembler
C is a high-level language which is complied rather than assembled .The processor of compilation is very complex, but the basic operation resembles that of assembly, with one exceptioneach line of the program can produce one or more machine code instructions (compared to the usual one-to-one correspondence between assembler and machine code). Most programs are written in a high level language such as C, rather than assembler .However, for some specific tasks, assembler me be a more appropriate language. Programs can be clearer, better structured. It is easy to use pre-written functions, which may be quite complicated. The C complier, if written carefully, can automatically take care of some problems, such as allocation of memory addresses.
11
Programming in C is a tremendous asset in those areas where we may want to use Assembly language but would rather keep it a simple to write and easy to maintain program. It has been said that a program written in C will pay a premium of a 20 to 50% increase in runtime because no high level language is as compact or as fast as Assembly Language. However, the time saved in coding can be tremendous, making it the most desirable language for many programming chores. In addition ,since most programs spend 90 percent of their operating time in only 10 percent or less of the code, it is possible to write a program in C , then rewrite a small portion of the code in Assembly language and approach the execution speed of the same program if it were written entirely in Assembly Language. C is standardized. C is ubiquitous. C is a low-level language. C is a small language. C is a permissive language
Strengths of C
Efficiency Portability Power
Flexibility Standard library Integration with UNIX
There are many multimedia files such as audios and videos we use in our day-to-day life .some of these are music files, personal videos and family photographs. It is very painful to maintain and manage huge collections of these multimedia files since there are not ordered. When we want a multimedia we usually search the particular file in a collection of files which are not integrated. To solve this problem we should employee a database to store, manage and retrieve these multimedia files. This will help us to manage the multimedia files easily and all the files will be integrated single Microsoft database files. I have implemented this software for audio, video and image files. And I have implemented DCT algorithm for image compression. Digital Image compression is one of the major areas of research in image processing. Digital compression is vital for several reasons. It provides the quality and reliability of digital technology, it packs more information into less transmission space, and it reduces the storage needed on disc or tape. For instance, to represent one frame of a video in the 0s and 1s of computer language, it takes over a megabyte of memory. Since there are 30 frames in the standard second of video, you would need 33MB of memory transfer or storage for one second of video. Compression methods can reduce this data
13
at nearly a 200:1 ratio-creating a much more manageable and cost-effective data stream. All digital images are collections of binary data (bits) that are organized into pixels .All digital images should be regarded as groups of pixels .pixels are the standard unit of measure that dictates the images size; not only the actual size that the image can be optimally reproduced (i.e. 4*6 inches), but also the size that the digital file will be (I.e.6 megabytes). The number of pixels per inch (PPT) is the resolution of the image file. Note that pixels per inch are not to be confused with dots per inch (DPI). DPI is a term that refers to printing and the amount of ink that actually is placed upon the print medium. DPI and PPI are completely unrelated to each other. However, as it has become common practice for scanner manufacturers and other so-called authorities to use DPI as a measure of resolution, either term is generally acceptable. The above review of image file basics refers to raw or uncompressed image files. Obviously, image files tend to be quite large in terms of the amount of disk space required to store them. A standard floppy disk has a capacity of about 1,400,000bytes (1.4MB), so even a single 4*6 image scanned at 300 ppi would requires 5 floppies to store it. With the advent of larger removable media such as zip disks and other similar storage options, this situation is becoming less a concern, but the sheer size of digital image files still demands a more efficient method of storage. File compression is quickly becoming standard
A Tool for Using MS Access as a Multimedia Database 14
procedure to facilitate not only compact storage but the movement of image files. Moving files is commonly done either by placing the file on a removable disk (floppy, ZIP disk, CD, etc) and physically transporting it, or by using what has become a globally used tool: Electronic Transfers. The basic idea of image compression techniques is to use an inevitable linear transformation to transform the given correlated image array to an array of uncorrelated variables that can be represented by much fewer number of bits compared to the original image array.
AN INTRODUCTION TO JPEG
JPEG (Pronounced jay-peg) is a standardized image compression mechanism .JPEG stands for Joint Photographic Experts Group, the original name of the committee that wrote the standard. JPEG is designed for compressing full-color or grayscale images of natural, real-world scenes. It works well on photographs, naturalistic artwork, and similar material; not so well on lettering, simple cartoons, or line drawings. JPEG handles only still images, but there is a related standard called MPEG for motion pictures. JPEG is lossy meaning that the decompressed image isnt quite the same as the one you started with. (There are
A Tool for Using MS Access as a Multimedia Database 15
lossless image compression algorithms, but JPEG achieves much greater compression than is possible with loss loss methods.)JPEG is designed to exploit known limitations of human eye, notably the fact that smaller color changes are perceived less accurately than small changes in brightness. Thus, JPEG is intended for compressing images that will be looked at by humans. If you plan to machine-analyze your images; the small errors introduced by JPEG may be a problem for you, even if they are invisible to the eye. A useful property of JPEG is that the degree of lossiness can be varied by adjusting compression parameters .This means that the image makers can tradeoff file size against output image quality. You can make extremely small files if you dont mind poor quality; this is useful for applications such as indexing image archives. Conversely, if you arent happy with the output quality at the default compression setting, you can jack up the quality until you are satisfied, and accept lesser compression. Another important aspect of JPEG is that decoders can trade off decoding speed against image quality, by using fast but inaccurate approximations to the required calculations. Some viewers obtain remarkable speedups in this way.(Encoders can f(i , j) F(u,v) Fq(u, v) DCT also trade accuracy for speed ,but theres Quantization usually less reason to make such a sacrifice when writing a file)
An Overview of JPEG
Coding Tables Header
Tables Entropy A Tool for Using MS Access as a Multimedia Database Coding RLC Data AC
16 Zigzag
The image is divided into 8*8 blocks .After this all operations are performed block wise. Each block is the input to the FDCT block. The 64 DCT coefficients are then uniformly quantized in conjunction with a 64-element quantization table (lossy encoding). All the quantized coefficients are ordered into a zigzag sequence. Finally Entropy coding is carried out.
MAJOR STEPS
The major steps involved in the image compression are
A Tool for Using MS Access as a Multimedia Database 17
o DCT (Discrete cosine transform) o Quantization o Zigzag Scan o DPCM on DC component o RLE on AC components o Entropy Coding
analyzing audio sample using the FFT.when we collect a set of sample points from an incoming audio signal, we end up with the representation of a signal in the time domain. That is, we have a collection of points that show what the voltage was for
A Tool for Using MS Access as a Multimedia Database 18
the input signal at each point in time. The FFT transforms the set of sample points into a set of frequency values that describes exactly the same signal. Each of the sample points represents the relative voltage or amplitude of the signal at the specific point in time. In the time domain representation of the signal, each of the points on the X-axis represents a different point in time, and each of the points on the Y-axis represents a specific magnitude of the signal. After processing the data points with an FFT, the X-axis no longer has the same meaning. Now, each point on the X-axis represents a specific frequency, and the Yaxis represents the magnitude of that frequency.
DCT
Another important point to make this type of implementation function is that the function is reversible. In principle, the same set of points can be processed through an
A Tool for Using MS Access as a Multimedia Database 19
inverse FFT function. The two transformation cycles are essentially loss less, Except for loss of precision resulting from rounding and truncation errors. The DCT is closely related to the Fourier transform, and produces a similar result. it takes a set of points from the spatial domain and transforms them into an identical representation in the frequency domain; however, we are going to introduce an additional complication in this particular instance .Instead of a two-dimensional signal plotted on a x and y-axis, the DCT will operate on a three dimensional signal plotted on an X, Y and Z-axis. If the signal is a graphical image, the X and Y-axes are the two dimensions of the screen .The amplitude of the signal in this case is simply the value of a pixel at a particular point on the screen .For example, an eight-bit value used to a represent a grey-scale value. So a graphical image displayed on the screen can be thought of as a complex threedimensional signal, with the value on the z-axis denoted by the color on the screen at a given point .this is the spatial representation of the signal. The DCT can be used to convert spatial information into frequency or Spectral information, with the X and Yaxes representing frequencies of the signal in two different dimensions .And like the FFT, there is an Inverse DCT (IDCT) function that can convert the spectral representation of the signal back to a spatial one.
The actual formula for the two-dimensional DCT is shown with its partner ,the IDCT .the DCT is performed on an N*N square matrix of pixels values, and it yields an N*N square matrix of frequency coefficients .The formula looks somewhat intimidating at first glance ,but it can be done with a relatively straightforward piece of code
DEFINITIONS
Discrete Cosine Transform (DCT): 7 F (u, v) = (u) (v) 4 cos (2i+1).u.Cos (2j+1).v .f (i, j) 16 16 i=0 j=0
() =
1/2 1
for =0 otherwise
Inverse Discrete Cosine Transform (IDCT): 7 F( i ,j) = 1 F(u,v) 4 u=0 v=0 16 () ={ 1 for =0 otherwise 16 7 (u) (v) cos (2i+1).u .cos (2j+1).v.
DCT implementation
A Tool for Using MS Access as a Multimedia Database 21
DCT implementations typically break the image down into smaller, more manageable blocks. The JPEG group selected an 8*8 block for the size of their DCT calculation .while increasing the size of DCT block would probably give better compression, doesnt take long to reach the point of diminishing returns. Research shows that the connections between the pixels tent to diminish quickly such that the pixels even 15 or 20 positions away are of very little use as predictors. The computation time would be longer, if we select big size of blocks .the JPEG committee elected to stick with 8*8.This type of compression is referred to as block coding.
22
The coefficient form of the DCT can be calculated using matrix operations. We first create an N*N matrix known as cosine transforms C. Once the cosine transform matrix has been built, we transpose it by rotating it around the main diagonal. The matrix is referred to in code as Ct, the transposed cosine transform matrix. Building this matrix is done only once during program initialization .both matrices can be built at the same time with a relatively short loop Once these two matrices have been built, we take advantage of the alternative definition of the DCT function. When multiplying two square matrices together, the
arithmetic cost of each element of the output matrix will be N multiplication operations and N addition operations .Since we perform two matrix multiplications to create the DCT matrix each element in the transformed DCT matrix was created at the cost if 2N multiplications and additions, a considerable improvement over the nested loop definition of the DCT.
23
185 -17 14 -8 23 -9 -13 -18 20 -34 26 -9 -10 10 13 -10 -23 -1 -8 -3 3 8 0 -5 9 -2 0 -7 7 -2 -2 14 -14 -8 -2 -3 -18 8 3 8 -1 -5 4 6 8 6 -18 3 -20 0 1 -11 17 18 15 0 -6 -1 0 -6 -7 -1
1 1
Quantization
The JPEG compression process is six step procedures, the first step being a DCT transformation.DCT is lossless transformation that prepares for the lossy or quantization, stage of the process. The DCT output matrix takes more space to store than the original matrix of pixels .The input to DCT function consists of 8 bit pixel values that come out can range from a low of-1024 to a high of +1023 occupying 11 bits. The drastic action used to reduce the number of bits required for storage of the DCT matrix is referred to as quantization. This is simply the process of reducing the number of bits needed to store an integer value by reducing the precision of the integer. Once a DCT image has been compressed, we can reduce the precision of the co-efficient more and more as we move away from the DC coefficient at the origin. The farther
A Tool for Using MS Access as a Multimedia Database 24
away from (0,0) the less the element contributes to the graphical image, so the less we care about maintaining rigorous precision in its value. The JPEG algorithm implements quantization using a quantization matrix. For every element position in the DCT matrix, a corresponding value in the quantization matrix gives a quantum value. The quantum value indicates what the step size is going to be for that element in that element in the compressed rendition of the picture, with values from 1 to 255. The elements that matter most to the picture will be encoded with a small step size, 1 offering the most precision. Values can become higher as we move away from the origin. The actual formula for quantization is quite simple. Quantized value (i, j) = DCT (i, j)/quantum (i, j) rounded to the nearest integer. It becomes clear that quantization values above 25 or perhaps 50 assure that virtually all higher. Frequency component will be rounded down to 0 only if the high frequency coefficients get up to unusually large values will they be encode as non-zero values. During decoding, the dequantization formula operates in reverse. DCT (i, j) = quantized value (i, j) * quantum (i, j)
25
Once
use large quantum values, you run the risk of generating large errors in the DCT output during dequantization. Fortunately, errors generated in the high frequency component during dequantization normally dont have a serious effect on the picture quality.
Quantization matrix
Clearly an enormous number of schemes could be used to define values in the quantization matrix .At least two experimental approaches can test different values. One measures the mathematical error found between an input and output image after it has been decompressed, trying to determine an acceptable level of error. A second approach tries to judge the effect of decompression on the human eye, which may not always correspond exactly with mathematically differences in the error levels. Since the quantization matrix can obviously be defined a run time when compression takes place, JPEG allows the use of any quantization matrix. The quantization tables used in the test code supplied with this program are created using a very simple algorithm. To determine the value of the quantum step size, the user inputs a single quality factor which should range from 1 to 25. Value larger than 25 would work, but the picture quality has degraded.
A Tool for Using MS Access as a Multimedia Database 26
For enough at quality level 25 to make going any further an exercise futility. The quantum level sets the difference between adjoining bands of the same quantization level.
3 5 7 9 11 13 15 17 5 7 9 11 13 15 17 19 7 9 11 13 15 17 19 21 9 11 13 15 17 19 21 23 11 13 15 17 19 21 23 25 13 15 17 19 21 23 25 27 15 17 19 21 23 25 27 29 17 19 21 23 25 27 29 31
These bands are oriented on diagonal lines across the matrix, so quantization levels of the same values are all roughly the same distance from the origin. An example of what the quantization matrix looks like with a quality factor of two as shown in figure.
27
As a result of this configuration, the DCT coefficient at (7, 7) would have to reach a value of 16 to be encoded as a value other than zero. This sets the threshold for the value of an element before it is going to contribute any meaningful information to the picture .Any contribution under the value of this threshold is simply thrown out. This is the exact point in the algorithm where the lossy effect takes place. The first DCT step is loss less except for minor mathematical precision loss and the step following quantization is a loss less encoding step. So this is the only place where we have a chance to actually discard data.
-1 -2
0 -1
0 -1
28
elected to handle zero values differently from other coefficient values. Instead of replying on Huffman or arithmetic coding to compress the zero values, they are coded using a run lengthencoding (RLE) algorithm. A simple code is developed that gives a count of consecutive zero values in the image. Since over half of the coefficients are quantized to zero in many images, this gives an opportunity for outstanding compression. One way to increase the length or runs is to reorder the coefficients in the zigzag sequence. Instead of compressing in row major order, as a programmer would probably do, the JPEG algorithm moves through the block along diagonal paths, selecting what should be highest value elements first and working its way toward the values likely to be lowest.
The actual path of zigzag sequence is shown in the figure. In the code used in this chapter, the diagonal sequences of quantization steps follow exactly the same lines, so the zigzag sequence should be optimal for our purposes.
29
Maps 8 * 8 to a 1 * 64 vector.
DPCM on DC Components
The Steps involved in this process are The DC component value in each 8*8 block is large and varies across blocks but is often close to that in the previous block. Differential Pulse Code Modulation (DPCM): Encode the difference between the current and previous 8 * 8 block Remember ,smaller number -> fewer bits
30
RLE on AC Components
The steps involved in this process
The 1*64 vectors have a lot of zeros in them, more so towards the end of the vector.
Higher up entries in the vector capture higher frequency (DCT) components which tend to be capturing less of the content. Could have been as a result of using a quantization table. Encode a series of 0s as a (skip, value) pair, where skip is the number of zeros and value is the next non-zero component. Send (0, 0) as end-of-block sentinel value.
0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 2
31
F (0, 0) is called the DC component and the rest of F ( i , j ) are called AC components.
Entropy coding
A run is defined as a sequence of identical characters .the run-length encoding technique takes advantage of the presence of runs and represents then in an abbreviated, compressed form. This technique is only efficient when at least two-character runs are transmitted, because for one-character runs, the code is twice as long as the character. This requires using a marker indicating that what is being transmitted is either run in an abbreviated form or a literal character. Three characters are needed to represent a run a compression marker, a literal marker and a counter. The problem of choosing the compression marker is especially delicate, since it should not be confused with a literal character being transmitted. Since compressing runs results in a sequence of three characters, this technique should be applied to runs of at least four characters. The maximum length of a run that can be represented by the triple is 255 for 8-bit ASCII. The run length coding is only modestly efficient text file in which only the blank character has a tendency to be repeated. In this case, a predecessor of this technique can be applied, null
32
suppression,
which
compress
only
runs
of
blanks,
which
eliminates the need to identify the character being compressed. Run-length encoding is very useful when applied to files, which are almost, guaranteed to have many runs of at least four characters. One example is relational databases. Run-length encoding is used in the compression of facsimile images, which are composed of combinations of black and white pixels. A serious drawback of run-length encoding is that it relies entirely on the occurrences of runs. In particular, this method taken by it is unable to recognize the high frequency of the occurrence of certain symbols, which call for short codes.
4. ALGORITHM
Here the standard JPEG image compression algorithm was implemented. This was done using the following. The image is divided into 8*8 blocks. After this all operations are performed block wise. Each block is the input to the FDCT block. The 64 DCT coefficients are then uniformly quantized in conjunction with a 64-element quantization table (lossy encoding)
A Tool for Using MS Access as a Multimedia Database 33
START
INITILIZATION
FORWARD DCT
INVERSE DCT
34
STOP
COMPRESSION IMAGES
Bitmap images
Compression
JPEG
35
DECOMPRESSION IMAGES
JPEG
Decompression
Bitmap images
INSERT IMAGES
Byte Array Converter
Bitmap Images
Compressio n
JPEG Images
Byte Array
User
Image Name
Databas e
EXTRACT IMAGES
A Tool for Using MS Access as a Multimedia Database 36
User
Search by name
Decompression
Bitmap images
Insert Audio
Audio
Database User
Audio
Database
Extract Audio
Audio User Search by Name Byte Array Converter
37
Audio
Insert Video
Video
Database User
38
Extract Video
Database
Video
User
Video
Search by Name
Video
Input design is a gateway between users and the database. They use these input screens is to perform operations and view their results. The designs of input focusing on controlling the amount of input required controlling the errors, avoid delay extra steps, and keeping the process simple. This system is designed in such a way that it is most user-friendly to all range of its users. Output screens play and important role in representing data and multimedia files back to the users of the system. At most care is taken to make it simple and easily understandable by the
A Tool for Using MS Access as a Multimedia Database 39
user. The output is given in the form files to the receiver, which is dynamically generated by the software. This gives great flexibility to the developer and also makes the system adaptable and easily upgradeable.
40
Although each test has a different purpose, all of them work to verify that all system elements have been properly integrated and perform allocated functions. If testing is conducted successfully, it will uncover errors in the software. As a secondary benefit, testing demonstrates that the software appears to be working according to the specification and that the performance requirements appear to have been met. In addition, data collected as testing is conducted, provides a good indication of software reliability and some indication of the software quality as a whole. However, testing cannot show the absence of defects, it can only show that software errors are present. All the tests should be traceable to customer
requirements .A good test has high probability of finding an error. To achieve this goal, the tester must understand the software and attempt to develop a mental picture of how the software might fail.
TESTING OBJECTIVES
A Tool for Using MS Access as a Multimedia Database 41
Testing is the process of executing a program with the intention of finding an error. A good test case is the one that has a high probability of finding an as-yet undiscovered error successful test is that which uncovers an as-yet undiscovered errors A successful test is that in which no errors are fond. The objective is to design tests that systematically uncover different classes of errors and do so with a minimum amount of time and effort.
SYSTEM TESTING
For every software project, there is an inherent conflict of interest that occurs as testing begins. The people who have build the software, are now asked to test the software. This seems harmless in itself, after all, who knows the program better than its developers? Unfortunately, these same developers have a vested interest in demonstrating that the program is error free, that it will be completed on schedule and within budget. From psychological point of view, software analysis and testing (along with coding) is constructive works. The software engineer creates a computer program, its documentation and data structures. When testing commences, there is subtle, yet definite attempt, to break the thing that the software engineer built. From
A Tool for Using MS Access as a Multimedia Database 42
the point of view of the builder, testing can be destructive. The primary objective of the test design is to derive a set of tests that has the highest likelihood for uncovering defects in the software. To accomplish this objective, two categories of test case designing techniques were used White Box Testing and Black box Testing. White Box Testing focuses on the program control structure. Test cases are derived to ensure that all statements in the program have executed at least once during testing and that all logical conditions have been exercised. White box testing is testing in the small implying that this test typically applied to small program components. Black Box Testing on the other hand broadens our focus and might be called testing in the large. Black box tests are designed to validate functional requirements without regard to the internal working of a program. Black Box testing focuses on the information domain of the software, deriving test coverage. The requirement for high quality software demands more systematic approach to testing. The specification states what the program should do and how it should perform under various conditions are tested. The test cases are developed for each condition or combination of conditions and submitted for processing.
43
By examining the results, the performance of the program according to specified requirements can be determined. This is not the study of the code and is not concerned about whether every instruction or path through the program is tested. Test cases are developed, that will result in the execution of every instruction in the program or module. It is to ensure that every path through the program is tested. A path is a specific combination of conditions that is handled by the program. Another strategy for software testing may be envisioned by moving outward along the development spiral. Unit testing begins at the vertex of the spiral and concentrates on each unit of the software as implemented from the source code. Testing progresses by moving outward along the spiral to integration testing where the focus is on the design and construction of the software architecture. Taking another turn outward of the spiral, we finally encounter validation testing.
INTEGRATION TESTING
Integration errors associated testing the is a systematic Many test technique modules for are
constructing the program structure by condition tests to uncover interfacing. combined into sub systems, which are then tested. This testing is a verification of the interface among system parts Integration test addressing the issues associated with the dual problems of verification and program construction. Black Box test case design techniques are the most prevalent during integration.
A Tool for Using MS Access as a Multimedia Database 44
The various unit-tested modules were integrated. Rigorous integration testing is conducted to make the application free of any interface errors that may occur during transactions.
ALPHA TESTING
The developer in collaboration does alpha testing with the end user. The developer guides the end user all the way while observing reactions and feedback Beta testing, on the other hand, releases the product to the end user. He is at liberty to produce as the requirements dictate. The user records all the problems (real and imaginary) that are encountered during beta testing and reports these to the developer at regular intervals. As a result of this the software developer makes modifications and then prepares for release of the software product to entire customer base.
IMPLEMENTATION
Implementation is the process of having the systems personal check out and put new equipment into use, training the users to install and try the new system and construct any file that are needed to use it. It is the final and important phase in the system life cycle. Depending on the size of the organization that is involved in using the application and the risk associated with its use, system
A Tool for Using MS Access as a Multimedia Database 45
developers may choose to carry out the operation in only one area of the firm, say, in one department or with only one or two persons. The term implementation has different meanings, ranging from the conversion of a basic application to complete replacement of computer system. The procedure is however, virtually the same. Implementation includes all the activities that take place to convert from old system to new. The new system may be totally new replacing an existing manual or automated system or it may be major modification to an existing system. The method of implementation and time scale to be adopted is found out initially. The system is tested properly and at the same time the users are trained in the new procedure. Proper implementation is essential to provide a reliable system to meet organization requirements. Successful implementation may not guarantee improvement in the organization using new system, but it will prevent improper installation. The implementation involves the following things. Proper planning Investigation of the system and constraints. Design the methods to achieve the change over. Training the staff in the changed phase. Evaluation of the change over method.
MAINTENANCE
A Tool for Using MS Access as a Multimedia Database 46
The
maintenance
phase
focuses
on
change
that
is
associated with error correction, adaptations required as the software environment evolves and changes due to enhancements brought about by changing customer requirements the and maintenance phase reapplies the steps of the definition development phase, but does so I the context of maintenance phase. Correction: Even with the best quality assurance activities, it is likely that the customer will uncover defects in the software. Correct maintenance changes the software to correct defects. Adaptation: Over time, the original environment for which the software was developed results in is likely to to change. the Adaptive to maintenance modification software
existing
accommodate to its external environment. Enhancement: As software is used, the customer/user will recognize additional functions that will provide benefits. Perfect maintenance extends the software beyond the original functional requirements. Prevention: Computer software deteriorates due to change and because of this, preventive maintenance, often called software engineering must be conducted to enable the software to serve the needs of its end users. In essence, the preventive
47
maintenance makes changes to computer programs so that they can be more easily corrected, adapted and enhanced.
7. OUTPUT SCREEN
Database
Image Table
Audio Table
48
Video Table
49
INSERT IMAGE
50
COMPRESSING IMAGE
51
DECOMPRESSING IMAGE
52
INSERT AUDIO
53
INSERT VIDEO
54
In my project I have implemented the coding to store retrieve and image multimedia in M.S.Access. In my project we have used DCT for image compression using C language. In DCT compression we have used discrete cosine transform for
A Tool for Using MS Access as a Multimedia Database 55
compression. We varied the threshold value in order to vary the compression ratios.
The audio compression algorithm mpeg layer 3(mp3) can implemented along with this to compress the audio files before storing it in the database and decompressing it when we retrieve it.
Rafel .C.Gonzalez & Richard .E.Woods (Addition Wesley Publishing company , 1993)
[3] Let us C
Yashavant Kanetkar
Source Code
MDI FORM
A Tool for Using MS Access as a Multimedia Database 57
Imports System.Windows.Forms Public Class MDI Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles NewToolStripMenuItem.Click Dim find As New frm_find find.MdiParent = Me find.Show() End Sub Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click Dim insert As New Form1 insert.MdiParent = Me insert.Show() End Sub Private Sub MDI_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click Dim convert As New frm_convert convert.MdiParent = Me convert.Show() End Sub
Dim delete As New frm_del delete.MdiParent = Me delete.Show() End Sub Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveAsToolStripMenuItem.Click Dim extract As New frm_extract extract.MdiParent = Me extract.Show() End Sub Private Sub InsertAudioToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InsertAudioToolStripMenuItem.Click Dim inserta As New frm_insa inserta.MdiParent = Me inserta.Show() End Sub Private Sub ExtractAudioToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExtractAudioToolStripMenuItem.Click Dim extracta As New frm_extracta extracta.MdiParent = Me extracta.Show() End Sub Private Sub DeleteAudioToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteAudioToolStripMenuItem.Click Dim deletea As New frm_dela deletea.MdiParent = Me deletea.Show() End Sub
59
Private Sub InsertVideoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InsertVideoToolStripMenuItem.Click Dim insertv As New frm_insv insertv.MdiParent = Me insertv.Show() End Sub Private Sub ExtractVideoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExtractVideoToolStripMenuItem.Click Dim extractv As New frm_extractv extractv.MdiParent = Me extractv.Show() End Sub Private Sub DeleteVideoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteVideoToolStripMenuItem.Click Dim deletev As New frm_delv deletev.MdiParent = Me deletev.Show() End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click Me.Close() End Sub End Class
60
FIND FORM
Imports System.Data.OleDb Imports System.IO Public Class frm_find Inherits System.Windows.Forms.Form Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OL EDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "DB.mdb;") Private Sub frm_find_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.MdiParent = MDI End Sub Private Sub DrawToScale(ByVal img As Image) PictureBox1.Image = New Bitmap(img) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click On Error GoTo fix Dim fn As String = TextBox1.Text Dim sql As String = "SELECT Photo FROM Images WHERE FileName='" & fn & "'" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) Dim b() As Byte b = cmd.ExecuteScalar() If b Is Nothing Then MsgBox("No Image Found") TextBox1.Text = "" ElseIf (b.Length > 0) Then Dim stream As New MemoryStream(b, True) stream.Write(b, 0, b.Length) DrawToScale(New Bitmap(stream)) stream.Close() End If conn.Close()
A Tool for Using MS Access as a Multimedia Database 61
fix:
COMPRESS FORM Imports System.IO Imports System.Data.OleDb Public Class frm_convert Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OL EDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "DB.mdb;Mode=ReadWrite;Persist Security Info=False") Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.MdiParent = MDI End Sub Private Sub JPGToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JPGToolStripMenuItem.Click On Error Resume Next With OpenFileDialog1 .CheckFileExists = True .FileName = "*.JPG" .AddExtension = True .DefaultExt = "*.JPG" .ShowDialog() PictureBox1.Image = New System.Drawing.Bitmap(.FileName) PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage End With End Sub
62
Private Sub BMPToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BMPToolStripMenuItem.Click On Error Resume Next Dim d As New System.Drawing.Bitmap(Module1.compress(PictureBox1)) Dim tmp As String = OpenFileDialog1.FileName() If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then My.Computer.Audio.Play("C:\Windows\Media\ringin.wav") MsgBox("Open a picture!") Exit Sub End If SaveFileDialog1.ShowDialog() tmp = SaveFileDialog1.FileName d.Save(tmp, System.Drawing.Imaging.ImageFormat.Bmp) Dim answer As MsgBoxResult If answer = MsgBoxResult.Yes Then MsgBox("Image Saved") End If End Sub Private Sub ToujoursVisibleToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) On Error Resume Next With OpenFileDialog1 .CheckFileExists = True .FileName = "*.ICO" .AddExtension = True .DefaultExt = "*.ICO" .ShowDialog() PictureBox1.Image = New System.Drawing.Bitmap(.FileName) PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage End With End Sub Private Sub BMPToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) On Error Resume Next Dim d As New System.Drawing.Bitmap(PictureBox1.Image)
A Tool for Using MS Access as a Multimedia Database 63
Dim tmp As String = OpenFileDialog1.FileName() If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then My.Computer.Audio.Play("C:\Windows\Media\ringin.wav") MsgBox("Open a picture!") Exit Sub End If tmp = Microsoft.VisualBasic.Replace(UCase(tmp), "GIF", "BMP") d.Save(tmp, System.Drawing.Imaging.ImageFormat.Bmp) Dim answer As MsgBoxResult answer = MsgBox("Save in BMP in the file of origin." & vbNewLine & "You finished?", MsgBoxStyle.YesNo) If answer = MsgBoxResult.Yes Then MsgBox("See you soon") End End If End Sub Private Sub JPGToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) On Error Resume Next Dim d As New System.Drawing.Bitmap(PictureBox1.Image) Dim tmp As String = OpenFileDialog1.FileName() If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then My.Computer.Audio.Play("C:\Windows\Media\ringin.wav") MsgBox("Open a picture!") Exit Sub End If tmp = Microsoft.VisualBasic.Replace(UCase(tmp), "GIF", "JPG") d.Save(tmp, System.Drawing.Imaging.ImageFormat.Jpeg) Dim answer As MsgBoxResult answer = MsgBox("Save in JPG in the file of origin." & vbNewLine & "You finished?", MsgBoxStyle.YesNo) If answer = MsgBoxResult.Yes Then MsgBox("See you soon") End End If End Sub
64
Private Sub ICOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ICOToolStripMenuItem.Click On Error Resume Next With OpenFileDialog1 .CheckFileExists = True .FileName = "*.BMP" .AddExtension = True .DefaultExt = "*.BMP" .ShowDialog() PictureBox1.Image = New System.Drawing.Bitmap(.FileName) PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage End With End Sub Private Sub JPGToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JPGToolStripMenuItem1.Click On Error Resume Next Dim d As New System.Drawing.Bitmap(Module1.compress(PictureBox1)) Dim tmp As String = OpenFileDialog1.FileName() If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then My.Computer.Audio.Play("C:\Windows\Media\ringin.wav") MsgBox("Open a picture!") Exit Sub End If SaveFileDialog2.ShowDialog() tmp = SaveFileDialog2.FileName d.Save(tmp, System.Drawing.Imaging.ImageFormat.Jpeg) Dim answer As MsgBoxResult If answer = MsgBoxResult.Yes Then MsgBox("Image Saved") End If End Sub Private Sub ToujoursVisibleToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToujoursVisibleToolStripMenuItem1.Click
A Tool for Using MS Access as a Multimedia Database 65
Me.TopMost = Not (Me.TopMost) End Sub Private Sub SauverJPGToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) On Error Resume Next Dim d As New System.Drawing.Bitmap(PictureBox1.Image) Dim tmp As String = OpenFileDialog1.FileName() If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then My.Computer.Audio.Play("C:\Windows\Media\ringin.wav") MsgBox("Open a picture!") Exit Sub End If tmp = Microsoft.VisualBasic.Replace(UCase(tmp), "ICO", "JPG") d.Save(tmp, System.Drawing.Imaging.ImageFormat.Jpeg) Dim answer As MsgBoxResult answer = MsgBox("Save in JPG in the file of origin." & vbNewLine & "You finished?", MsgBoxStyle.YesNo) If answer = MsgBoxResult.Yes Then MsgBox("See you soon") End End If End Sub Private Sub SauverBMPToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) On Error Resume Next Dim d As New System.Drawing.Bitmap(PictureBox1.Image) Dim tmp As String = OpenFileDialog1.FileName() If PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then My.Computer.Audio.Play("C:\Windows\Media\ringin.wav") MsgBox("Open a picture!") Exit Sub End If tmp = Microsoft.VisualBasic.Replace(UCase(tmp), "ICO", "BMP") d.Save(tmp, System.Drawing.Imaging.ImageFormat.Bmp) Dim answer As MsgBoxResult answer = MsgBox("Save in BMP in the file of origin." & vbNewLine & "You finished?", MsgBoxStyle.YesNo) If answer = MsgBoxResult.Yes Then
A Tool for Using MS Access as a Multimedia Database 66
MsgBox("See you soon") End End If End Sub End Class INSERT IMAGE FORM Imports System.Data.OleDb Imports System.IO Public Class Form1 Inherits System.Windows.Forms.Form Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OL EDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "DB.mdb;Mode=ReadWrite;Persist Security Info=False") Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click On Error GoTo fix OpenFileDialog1.ShowDialog() PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName) fix: Exit Sub End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim f As Integer = 0 On Error GoTo fix Dim fs As FileStream = New FileStream(OpenFileDialog1.FileName, FileMode.Open, FileAccess.Read) Dim s As String = TextBox1.Text Dim r As BinaryReader = New BinaryReader(fs) Dim FileByteArray(fs.Length - 1) As Byte r.Read(FileByteArray, 0, CInt(fs.Length)) Dim sql As String = "INSERT INTO Images (Filename,Photo) VALUES (?,?)"
A Tool for Using MS Access as a Multimedia Database 67
Dim cmd As New System.Data.OleDb.OleDbCommand(sql, conn) cmd.Parameters.Add("@Filename", System.Data.OleDb.OleDbType.VarChar).Value = TextBox1.Text cmd.Parameters.Add("@Photo", System.Data.OleDb.OleDbType.Binary).Value = FileByteArray conn.Open() cmd.ExecuteNonQuery() MessageBox.Show("Image Succesfully inserted !", "Image Save and Read", MessageBoxButtons.OK, MessageBoxIcon.Information) conn.Close() f=1 fix: If f = 0 Then MsgBox("Already the image name exists; Please enter another name") TextBox1.Text = "" End If Exit Sub End Sub Private Sub DrawToScale(ByVal img As Image) PictureBox1.Image = New Bitmap(img) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click On Error GoTo fix Dim fn As String = InputBox("Enter File Name:") Dim sql As String = "SELECT Photo FROM Images WHERE FileName='" & fn & "'" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) TextBox1.Text = fn Dim b() As Byte b = cmd.ExecuteScalar() If (b.Length > 0) Then Dim stream As New MemoryStream(b, True) stream.Write(b, 0, b.Length) DrawToScale(New Bitmap(stream))
A Tool for Using MS Access as a Multimedia Database 68
fix:
Exit Sub End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Me.Hide() End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click On Error GoTo fix Dim fn As String = InputBox("Enter name to delete") Dim sql As String = "DELETE FROM Images WHERE FileName='" & fn & "'" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) cmd.ExecuteNonQuery() MessageBox.Show("Image Succesfully deleted !", "Image Save and Read", MessageBoxButtons.OK, MessageBoxIcon.Information) conn.Close() fix: Exit Sub End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.MdiParent = MDI End Sub End Class
Imports System.Data.OleDb Imports System.IO Public Class frm_extract Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OL EDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "DB.mdb;Mode=ReadWrite;Persist Security Info=False") Private Sub ComboBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.GotFocus ComboBox1.Items.Clear() On Error GoTo fix Dim sql As String = "SELECT FileName FROM Images" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) Dim dr As OleDbDataReader = cmd.ExecuteReader While dr.Read ComboBox1.Items.Add(dr.GetValue(0).ToString()) End While dr.Close() conn.Close() fix: Exit Sub End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged On Error GoTo fix Dim fn As String = ComboBox1.SelectedItem.ToString Dim sql As String = "SELECT Photo FROM Images WHERE FileName='" & fn & "'" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) Dim b() As Byte b = cmd.ExecuteScalar() If (b.Length > 0) Then Dim stream As New MemoryStream(b, True) stream.Write(b, 0, b.Length) DrawToScale(New Bitmap(stream)) stream.Close()
A Tool for Using MS Access as a Multimedia Database 70
End If conn.Close() fix: Exit Sub End Sub Private Sub DrawToScale(ByVal img As Image) PictureBox1.Image = New Bitmap(img) End Sub Private Sub frm_extract_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.MdiParent = MDI End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If SaveFileDialog1.ShowDialog() <> Windows.Forms.DialogResult.Cancel Then Dim d As New System.Drawing.Bitmap(PictureBox1.Image) Dim tmp As String = SaveFileDialog1.FileName d.Save(tmp, System.Drawing.Imaging.ImageFormat.Bmp) MsgBox("file saved") End If End Sub End Class DELETE IMAGE FORM Imports System.Data.OleDb Imports System.IO Public Class frm_del Inherits System.Windows.Forms.Form Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OL EDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "DB.mdb;Mode=ReadWrite;Persist Security Info=False") Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If MsgBox(" Are you sure you want to delete the image ? ", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
A Tool for Using MS Access as a Multimedia Database 71
On Error GoTo mfix Dim fn As String = ComboBox1.SelectedItem.ToString Dim Sql As String = "DELETE FROM Images WHERE FileName='" & Trim(fn) & "'" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(Sql, conn) cmd.ExecuteNonQuery() MessageBox.Show("Image Succesfully deleted !", "Image Save and Read", MessageBoxButtons.OK, MessageBoxIcon.Information) PictureBox1.Image = Image.FromFile("c:\emp.bmp") ComboBox1.Text = "" conn.Close() Else PictureBox1.Image = Image.FromFile("C:\emp.bmp") End If mfix: Exit Sub End Sub Private Sub DrawToScale(ByVal img As Image) PictureBox1.Image = New Bitmap(img) End Sub Private Sub frm_del_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.MdiParent = MDI End Sub Private Sub ComboBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.GotFocus ComboBox1.Items.Clear() On Error GoTo fix Dim sql As String = "SELECT FileName FROM Images" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) Dim dr As OleDbDataReader = cmd.ExecuteReader While dr.Read ComboBox1.Items.Add(dr.GetValue(0).ToString()) End While dr.Close() conn.Close() fix:
A Tool for Using MS Access as a Multimedia Database 72
Exit Sub End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged On Error GoTo fix Dim fn As String = ComboBox1.SelectedItem.ToString Dim sql As String = "SELECT Photo FROM Images WHERE FileName='" & fn & "'" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) Dim b() As Byte b = cmd.ExecuteScalar() If (b.Length > 0) Then Dim stream As New MemoryStream(b, True) stream.Write(b, 0, b.Length) DrawToScale(New Bitmap(stream)) stream.Close() End If conn.Close() fix: Exit Sub End Sub End Class INSERT AUDIO FORM Imports System.Data.OleDb Imports System.IO Public Class frm_insa Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OL EDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "DB.mdb;Mode=ReadWrite;Persist Security Info=False") Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click On Error GoTo fix OpenFileDialog1.ShowDialog() mp.openPlayer(OpenFileDialog1.FileName.ToString)
A Tool for Using MS Access as a Multimedia Database 73
fix: End Sub Private Sub frm_insa_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.MdiParent = MDI End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim f As Boolean = False On Error GoTo fix Dim fs As FileStream = New FileStream(OpenFileDialog1.FileName, FileMode.Open, FileAccess.Read) Dim s As String = TextBox1.Text Dim r As BinaryReader = New BinaryReader(fs) Dim FileByteArray(fs.Length - 1) As Byte r.Read(FileByteArray, 0, CInt(fs.Length)) Dim sql As String = "INSERT INTO audio (Filename,audio) VALUES (?,?)" Dim cmd As New System.Data.OleDb.OleDbCommand(sql, conn) cmd.Parameters.Add("@Filename", System.Data.OleDb.OleDbType.VarChar).Value = TextBox1.Text cmd.Parameters.Add("@audio", System.Data.OleDb.OleDbType.Binary).Value = FileByteArray conn.Open() cmd.ExecuteNonQuery() MessageBox.Show("Audio Succesfully inserted !", "Image Save and Read", MessageBoxButtons.OK, MessageBoxIcon.Information) conn.Close() f = True fix: If f = False Then MsgBox("Already the audio name exists; Please enter another name") End If TextBox1.Text = "" Exit Sub End Sub
A Tool for Using MS Access as a Multimedia Database 74
End Class
EXTRACT AUDIO FORM Imports System.Data.OleDb Imports System.IO Public Class frm_extracta Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OL EDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "DB.mdb;Mode=ReadWrite;Persist Security Info=False") Private Sub ComboBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.GotFocus ComboBox1.Items.Clear() On Error GoTo fix Dim sql As String = "SELECT FileName FROM audio" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) Dim dr As OleDbDataReader = cmd.ExecuteReader While dr.Read ComboBox1.Items.Add(dr.GetValue(0).ToString()) End While dr.Close() conn.Close() fix: Exit Sub End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged On Error GoTo fix Dim fn As String = ComboBox1.SelectedItem.ToString Dim sql As String = "SELECT audio FROM audio WHERE FileName='" & fn & "'" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) Dim b() As Byte
A Tool for Using MS Access as a Multimedia Database 75
b = cmd.ExecuteScalar() If (b.Length > 0) Then Dim stream As New MemoryStream(b, True) Dim fs As FileStream = New FileStream("C:\x.wav", FileMode.OpenOrCreate, FileAccess.Write) fs.Write(b, 0, b.Length) fs.Close() mp.openPlayer("C:\x.wav") End If conn.Close() fix: Exit Sub End Sub Private Sub frm_extracta_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.MdiParent = MDI End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If SaveFileDialog1.ShowDialog() <> Windows.Forms.DialogResult.Cancel Then Dim pt As String = SaveFileDialog1.FileName File.Copy("c:\x.wav", pt, True) Else ComboBox1.Text = "" End If End Sub End Class
DELETE AUDIO FORM Imports System.Data.OleDb Imports System.IO Public Class frm_dela Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OL
A Tool for Using MS Access as a Multimedia Database 76
EDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "DB.mdb;Mode=ReadWrite;Persist Security Info=False") Private Sub ComboBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.GotFocus ComboBox1.Items.Clear() On Error GoTo fix Dim sql As String = "SELECT FileName FROM audio" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) Dim dr As OleDbDataReader = cmd.ExecuteReader While dr.Read ComboBox1.Items.Add(dr.GetValue(0).ToString()) End While dr.Close() conn.Close() fix: Exit Sub End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged On Error GoTo fix Dim fn As String = ComboBox1.SelectedItem.ToString Dim sql As String = "SELECT audio FROM audio WHERE FileName='" & fn & "'" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) Dim b() As Byte b = cmd.ExecuteScalar() If (b.Length > 0) Then Dim stream As New MemoryStream(b, True) Dim fs As FileStream = New FileStream("C:\x.wav", FileMode.OpenOrCreate, FileAccess.Write) fs.Write(b, 0, b.Length) fs.Close() mp.openPlayer("C:\x.wav") End If conn.Close() fix:
A Tool for Using MS Access as a Multimedia Database 77
Exit Sub End Sub Private Sub frm_dela_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.MdiParent = MDI End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If MsgBox(" Are you sure you want to delete the audio ? ", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then On Error GoTo mfix Dim fn As String = Trim(ComboBox1.Text) Dim Sql As String = "DELETE FROM audio WHERE FileName='" & Trim(fn) & "'" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(Sql, conn) cmd.ExecuteNonQuery() MessageBox.Show("Audio Succesfully deleted !", "Audio Delete Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information) ComboBox1.Text = "" conn.Close() Else ComboBox1.Text = "" End If mfix: Exit Sub End Sub End Class INSERT VIDEO FORM Imports System.Data.OleDb Imports System.IO Public Class frm_insv Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OL
A Tool for Using MS Access as a Multimedia Database 78
EDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "DB.mdb;Mode=ReadWrite;Persist Security Info=False") Private Sub frm_insv_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.MdiParent = MDI End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click On Error GoTo fix OpenFileDialog1.ShowDialog() mp.openPlayer(OpenFileDialog1.FileName) fix: End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim f As Boolean = False On Error GoTo fix Dim fs As FileStream = New FileStream(OpenFileDialog1.FileName, FileMode.Open, FileAccess.Read) Dim s As String = TextBox1.Text Dim r As BinaryReader = New BinaryReader(fs) Dim FileByteArray(fs.Length - 1) As Byte r.Read(FileByteArray, 0, CInt(fs.Length)) Dim sql As String = "INSERT INTO video (Filename,video) VALUES (?,?)" Dim cmd As New System.Data.OleDb.OleDbCommand(sql, conn) cmd.Parameters.Add("@Filename", System.Data.OleDb.OleDbType.VarChar).Value = TextBox1.Text cmd.Parameters.Add("@video", System.Data.OleDb.OleDbType.Binary).Value = FileByteArray conn.Open() cmd.ExecuteNonQuery() MessageBox.Show("video Succesfully inserted !", "Image Save and Read", MessageBoxButtons.OK, MessageBoxIcon.Information) conn.Close() f = True fix:
A Tool for Using MS Access as a Multimedia Database 79
If f = False Then MsgBox("Already the video name exists; Please enter another name") End If TextBox1.Text = "" Exit Sub End Sub End Class EXTRACT VIDEO FORM Imports System.Data.OleDb Imports System.IO Public Class frm_extractv Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OL EDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "DB.mdb;Mode=ReadWrite;Persist Security Info=False") Private Sub frm_extractv_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.MdiParent = MDI End Sub Private Sub ComboBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.GotFocus ComboBox1.Items.Clear() On Error GoTo fix Dim sql As String = "SELECT FileName FROM video" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) Dim dr As OleDbDataReader = cmd.ExecuteReader While dr.Read ComboBox1.Items.Add(dr.GetValue(0).ToString()) End While dr.Close() conn.Close() fix: Exit Sub End Sub
80
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged On Error GoTo fix Dim fn As String = ComboBox1.SelectedItem.ToString Dim sql As String = "SELECT video FROM video WHERE FileName='" & fn & "'" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) Dim b() As Byte b = cmd.ExecuteScalar() If (b.Length > 0) Then Dim stream As New MemoryStream(b, True) Dim fs As FileStream = New FileStream("C:\x.avi", FileMode.OpenOrCreate, FileAccess.Write) fs.Write(b, 0, b.Length) fs.Close() mp.openPlayer("C:\x.avi") End If conn.Close() fix: Exit Sub End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If SaveFileDialog1.ShowDialog() <> Windows.Forms.DialogResult.Cancel Then Dim pt As String = SaveFileDialog1.FileName File.Copy("c:\x.avi", pt, True) Else ComboBox1.Text = "" End If End Sub End Class
Imports System.Data.OleDb Imports System.IO Public Class frm_delv Dim conn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OL EDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "DB.mdb;Mode=ReadWrite;Persist Security Info=False") Private Sub frm_delv_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.MdiParent = MDI End Sub Private Sub ComboBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.GotFocus On Error GoTo fix ComboBox1.Items.Clear() Dim sql As String = "SELECT FileName FROM video" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) Dim dr As OleDbDataReader = cmd.ExecuteReader While dr.Read ComboBox1.Items.Add(dr.GetValue(0).ToString()) End While dr.Close() conn.Close() fix: Exit Sub End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged On Error GoTo fix Dim fn As String = ComboBox1.SelectedItem.ToString Dim sql As String = "SELECT video FROM video WHERE FileName='" & fn & "'" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(sql, conn) Dim b() As Byte
A Tool for Using MS Access as a Multimedia Database 82
b = cmd.ExecuteScalar() If (b.Length > 0) Then Dim stream As New MemoryStream(b, True) Dim fs As FileStream = New FileStream("C:\x.avi", FileMode.OpenOrCreate, FileAccess.Write) fs.Write(b, 0, b.Length) fs.Close() mp.openPlayer("C:\x.avi") End If conn.Close() fix: Exit Sub End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If MsgBox(" Are you sure you want to delete the video ? ", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then On Error GoTo mfix Dim fn As String = Trim(ComboBox1.Text) Dim Sql As String = "DELETE FROM video WHERE FileName='" & Trim(fn) & "'" conn.Open() Dim cmd As OleDbCommand = New OleDbCommand(Sql, conn) cmd.ExecuteNonQuery() MessageBox.Show("video Succesfully deleted !", "video Delete Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information) ComboBox1.Text = "" conn.Close() Else ComboBox1.Text = "" End If mfix: Exit Sub End Sub End Class
83
MODULE Module Module1 Public Function compress(ByVal img As System.Windows.Forms.PictureBox) As System.Drawing.Bitmap Shell("C:\MAIN-C.exe temp.bmp temp.jpg") Return img.Image End Function Public Function decompress(ByVal img As System.Windows.Forms.PictureBox) As System.Drawing.Bitmap Shell("C:\MAIN-E.exe temp.jpg temp.bmp") Return img.Image End Function End Module
DCT.C
#include<stdio.h> #include<stdlib.h> #include<math.h> #include"bitio.h" #include"errhand.h" #define ROWS 200 #define COLS 320 #define N 8 #define ROUND(a) (((a)<0)?(int)((a)-0.5):\(int)((a)+0.5)) char*CompressionName="DCT compression"; char*Usage ="infile outfile[quality]\nquality from 0-25"; #ifdef_STDC_
A Tool for Using MS Access as a Multimedia Database 84
void Initalize(int quality); void ReadPixelStrip(FILE*input,unsigned char strip[N][COLS]); int InputCode(BIT_FILE*input); void ReadDCTData(BIT_FILE*input,int input_data[N][N]); void OutputCode(BIT_FILE*output_file,int code); void WriteDCTData(BIT_FILE*output_file,int output_data[N][N]); void WritePixelStrip(FILE*output,unsigned char strip[N][COLS]); void ForwardDCT(unsigned char*input[N],int output[N][N]); void InverseDCT(int input[N][N],unsigned char*output[N]); void CompressFile(FILE*input,BIT_FILE*output,int argc,char*argv[]); void ExpandFile(BIT_FILE*input,FILE*output,int argc,char*argv[]); #else void Initalize(); void ReadPixelStrip(); int InputCode(); void ReadDCTData(); void OutputCode(); void WriteDCTData(); void WritePixelStrip(); void Forward(); void CompressFile(); void ExpandFile(); #endif unsigned char PixelStrip[N][COLS]; double c[N][N]; doublect[N][N]; int InputRunLength; int OutputRunLength; int Quantum[N][N]; struct zigzag{ int row; int col; }zigzag[N*N]={ {0,0}, {0,1},{1,0}, {2,0},{1,1},{0,2}, {0,3},{1,2},{2,1},{3,0}, {4,0},{3,1},{2,2},{1,3},{0,4}, {0,5},{1,4},{2,3},{3,2},{4,1},{5,0}, {6,0},{5,1},{4,2},{3,3},{2,4},{1,5},{0,6},
A Tool for Using MS Access as a Multimedia Database 85
{7,0},
void Initalize(quality) int quality; { int i; int j; double pi=atan(1.0)*4.0; for(i=0;i<N;i++) for(j=0;j<N;j++) Quantum[i][j]=1+((1+i+j)*quality); OutputRunLength=0; InputRunLength=0; for(j=0;j<N;j++) { c[0][j]=1.0/sqrt((double)N); Ct[j][0]=c[0][j]; } for(i=1;i<N;i++) { for(j=0;j<N;j++) { c[i][j]=sqrt(2.0/N)*cos(pi*(2*j+1)*i/(2.0*N)); Ct[j][i]=C[i][j]; }}} void ReadPixelStrip(input,strip) FILE*input; unsigned char strip[N][COLS]; { int row; int col; int c; for(row=0;row<N;row++) for(col=0;col<COLS;col++){ c=getc(input); if(c==EOF) fatal_error("ERROR reading input grey scale file");
A Tool for Using MS Access as a Multimedia Database 86
strip[row][col]=(unsigned char)c; }} int InputCode(input_file) BIT_FILE*input_file; { int bit_count; int result; if(InputRunLength>0){ InputRunLength--; return(0); } bit_count=(int)InputBits(input_file,2); if(bit_count==0){ InputRunLength=(int)InputBits(input_file,4); return(0); } if(bit_count==1){ InputRunLength=(int)InputBits(input_file,1)+1; else bit_count=(int)InputBits(input_file,2)+(bit_count<<2)-5; result=(int)InputBits(input_file,bit_count); if(result& (1<<(bit_count-1))) return(result); return(result-(1<<bit_count)+1); } void ReadDCTData(input_file,input_data) BIT_FILe*input_file; int input_data[N][N]; { int i; int row; int col; for(i=0;i<(N*N);i++){ row=ZigZag[i].row; col=ZigZag[i].col; input_data[row][col]=inputCode(input_file)*Quantum[row][col]; }} void OutputCode(output_file,code) BIT_FILE*output_file; int code; {
A Tool for Using MS Access as a Multimedia Database 87
int top_of_range; int abs_code; int bit_count; if(code==0){ OutputRunLength++; return; } if(OutputRunLength!=0){ while(OutputRunLength>0){ OutputBits(output_file,0l,2); if(OutputRunLength<=16){ OutputBits(output_file,(unsigned long) (OutputRunLength-1),4); OutputRunLength=0; }else{ OutputBits(output_file,15l,4); OutputRunLength-=16; }}} if(code<0) abs_code=-code; else abs_code=code; top_of_range=1; bit_count=1; while(abs_code>top_of_range){ bit_count++; top_of_range=((top_of_range + 1)*2)-1; } if(bit_count<3) OutputBits(output_file,(unsigned long) (bit_count+1),3); else OutputBits(output_file,(unsigned long) (bit_count+5),4); if(code>0) OutputBits(output_file,(unsigned long)code,bit_count); else OutputBits(output_file,(unsigned long) (code+top_of_range),bit_count);}
A Tool for Using MS Access as a Multimedia Database 88
void WriteDCTData(output_file,output_data) BIT_FILE*output_file; int output_data[N][N]; { int i; int row; int col; double result; for(i=0;i<(N*N);i++) row=ZigZag[i].row; col=ZigZag[i].col; result=output_data[row][col]/Quantum[row][col]; OutputCode(output_file,ROUND(result)); }} void WritePixelStrip(output,strip) FILE*output; unsigned char strip[N][COLS]; { int row; int col; for(row=0;row<N;row++) for(col=0;col<COLS;col++) putc(strip[row][col],output); } void ForwardDCT(input,output) unsigned char *input[N]; int output[N][N]; { double temp[N][N]; double temp1; int i; int j; int k; for(i=0;i<N;i++) { for(j=0;j<N;j++) { temp[i][j]=0.0; for(k=0;k<N;k++) temp[i][j]+=((int)input[i][k]-128)*ct[k][j]; } }
A Tool for Using MS Access as a Multimedia Database 89
for(i=0;i<N;i++){ for(j=o;j<N;j++){ temp1=0.0; for(k=0;k<N;k++) temp1+=c[i][k]*temp[k][j]; output[i][j]=ROUND(temp1); }}} void InverseDCT(input,output) int input[N][N]; unsigned char *output[N]; { double temp[N][N]; double temp1; int i; int j; int k; for(i=0;i<N;i++) { for(j=0;j<N;j++) { temp[i][j]=0.0; for(k=0;k<N;k++) temp[i][j]+=input[i][k]*c[k][j]; }} for(i=0;i<N;i++) { for(j=0;j<N;j++) { temp1=0.0; for(k=0;k<N;k++) temp1+=Ct[i][k]*temp[k][j]; temp1+=128.0; if(temp1<0) output[i][j]=0; elseif(temp1>255) output[i][j]=255; else output[i][j]=(unsigned char)ROUND(temp1); }}} void CompressFile(input,output,argc,argv) FILE*input; BIT_FILE*output; int argc; char*argv[];
A Tool for Using MS Access as a Multimedia Database 90
int row; int col; int i; unsigned char*input_array[N]; int output_array[N][N]; int quality; if(argc-->0) quality=atoi(argv[0]); else quality=3; if(quality<0||quality>50) fatal_error("Illegal quality factor of%d\n",quality); printf("Using quality factor of%d\n",quality); Initialize(quality); OutputBits(output,(unsigned long)quality,8); for(row=0;row<ROWS;row+=N){ ReadPixelStrip(input,PixelStrip); for(col=0;col<COLS;col+=N){ for(i=0;i<N;i++) input_array[i]=PixelStrip[i]+col; ForwardDCT(input_array,output_array); WriteDCTData(output,output_array); }} OutputCode(output,1); while(argc-->0) printf("UNused argument:%s\n",*argv++); } void ExpandFile(input,output,argc,argv) BIT_FILE*input; FILE*output; int argc; char*argv[]; { int row; int col; int i; int input_array[N][N]; unsigned char*output_array[N]; int quality; quality=(int)InputBits(input,8); printf("Using quality factor of%d\n",quality);
A Tool for Using MS Access as a Multimedia Database 91
Initialize(quality); for(row=0;row<ROWS;row+=N){ for(col=0;col<COLS;col+=N){ for(i=0;i<N;i++) output_array[i]=PixelStrip[i]+col; ReadDCTData(input,input_array); InverseDCT(input_array,output_array); } WritePixelStrip(output,PixelStrip); } while(argc-->0) printf("Unused argument:%s\n",*argv++); }
BITIO.C #include<stdio.h> #include<stdlib.h> #include"bitio.h" #include"errhand.h" #define PACIFIER_COUNT2047 BIT_FILE*OpenOutputBitFile(name) char*name; { BIT_FILE*bit_file; bit_file=(BIT_FILE*)calloc(1,sizeof(BIT_FILE)); if(bit_file==NULL) return(bit_file); bit_file->file=fopen(name,"wb"); bit_file->rack=0; bit_file->mask=0*80; bit_file->pacifier_counter=0; return(bit_file); } BIT_FILE*OpenInputBitFile (name) Char*name; {
A Tool for Using MS Access as a Multimedia Database 92
BIT_FILE*bit_file; bit_file= (BIT_FILE*) calloc (1, sizeof (BIT_FILE)); if (bit_file==NULL) return(bit_file); bit_file->file=fopen(name,"rb"); bit_file->rack=0; bit_file->mask=0*80; bit file->pacifier counter=0; Return(bit_file); } void CloseOutputBitFile(bit_file) BIT_FILE*bit_file; { if(bit_file->mask!=0*80) if(putc(bit_file->rack,bit_file->file)!=bit_file->rack) fatal_error("FATAL error in CloseBitFile!\n"); fClose(bit_file->file); free((char*)bit_file) } void CloseInputBitFile(bit_file) BIT_FILE*bit_file; { fClose(bit_file->file); free((char*)bit_file) } void OutputBit(bit_file,bit) BIT_FILE*bit_file; int bit; { if(bit) bit_file->rack|= bit_file->mask; bit_file->mask>>=1; if(bit_file->mask==0){ if(putc(bit_file->rack,bit_file->file)!=bit_file->rack) fatal_error("FATAL error in OutputBit!\n"); else if((bit_file->pacifier_counter++ & PACIFIER_COUNT)==0) putc('.',stdout); bit_file->rack=0; bit_file->mask=0*80; }} void OutputBits(bit_file,code,count)
A Tool for Using MS Access as a Multimedia Database 93
BIT_FILE*bit_file; unsigned longcode; int count; { unsigned long mask; mask=1l<<(count-1); while(mask!=0){ if(mask & code) bit_file->rack|= bit_file->mask; bit_file->mask>>=1; if(bit_file->mask==0){ if(putc(bit_file->rack,bit_file->file)!=bit_file->rack) fatal_error("FATAL error in OutputBit!\n"); else if((bit_file->pacifier_counter++ & PACIFIER_COUNT)==0) putc('.',stdout); bit_file->rack=0; bit_file->mask=0*80; } mask>>=1; }} int InputBit(bit_file) BIT_FILE*bit_file; { int value; if(bit_file->mask==0*80){ bit_file->rack=getc(bit_file->file); if(bit_file->rack==EOF) fatal_error("FATAL error in OutputBit!\n"); if((bit_file->pacifier_counter++ & PACIFIER_COUNT)==0) putc('.',stdout); } value=bit_file->rack & bit_file->mask; bit_file->mask>>=1; if(bit_file->mask==0) bit_file->mask=0*80; return(value?1:0); } unsigned long InputBits(bit_file,bit_count) BIT_FILE*bit_file; int bit_count;{ unsigned long mask;
A Tool for Using MS Access as a Multimedia Database 94
unsigned long return_value; mask=1l<<(bit count-1); return_value=0; while(mask!=0){ if(bit_file->mask==0*80){ bit_file->rack=getc(bit_file->file); if(bit_file->rack==EOF) fatal_error("FATAL error in InputBit!\n"); if((bit_file->pacifier_counter++ & PACIFIER_COUNT)==0) putc('.',stdout); } if(bit_file->rack & bit_file->mask) return_value|=mask; mask>>=1; bit_file->mask>>=1; if(bit_file->mask==0) bit_file->mask=0*80; } return(return_value);} void FilePrintBinary(file,code,bits) FILE*file; unsigned intcode; int bits; { unsigned int mask; mask=1<<(bits-1); while(mask!=0) { if(code & mask) fputc('1',file); else fputc('0',file); mask>>=1; }} #include<stdio.h> #include<stdlib.h> void cal_fsize(FILE*input,FILE*output,char fname[]) { long size1,size2; /*ip_file=fopen(cfname,"r"); op_file=fopen(ofname,"r");*/
A Tool for Using MS Access as a Multimedia Database 95
fseek(input,0l,SEEK_END); size1=ftell(input); fseek(output,0l,SEEK_END); size2=ftell(output); printf("\n\t\tInput Size:%u\n",size1); if(strcmp(fname,"cheetah1.bmp")==0) { size2=31275; } elseif(strcmp(fname,"clown1.bmp")==0) { size2=51020; } elseif(strcmp(fname,"rose1.bmp")==0) { size2=36078; } printf("\n\t\tOutput Size:%u\n",size2); printf("\n\n\t\t Compression Ratio %5.3f\%",(1-(float)(size2)/ (size1))*100); } void cal_desize(FILE*ip_file,FILE*op_file,char fname[]) { long size1,size2; FILE*ip1_file; fseek(ip_file,0l,SEEK_END); size1=ftell(ip_file); fseek(op_file,0l,SEEK_END); size2=ftell(op_file); ip1_file=fopen(fname,"r"); fseek(ip1_file,0l,SEEK_END); size1=ftell(ip1_file); if(strcmp(fname,"cheetah1.bmp")==0) { size1=31275; } elseif(strcmp(fname,"clown1.bmp")==0) { size1=51020; } elseif(strcmp(fname,"rose1.bmp")==0) {
A Tool for Using MS Access as a Multimedia Database 96
size1=36078; } printf("\n\t\t Compressed Size"%u\n",size1); printf("\n\t\t DeCompressed Size"%u/n",size2); printf("\n\t\t DeCompressed Size"%5.3f%",(1-(float)(size1)/ (size2))*100); } GS.C #include<stdio.h> #include<stdlib.h> #include<dos.h> #include<conio.h> main(int argc,char*argv[]) union REGS rin; union REGS rout; int i; FILE*file; char far*video; if(argc<2){ printf("usage : gs file\n\n"); exit(1); { rin.h.ah=0; rin.h.al=0*13; int86(0*10,&rin,&rout); rin.h.ah-0*10; rin.h.al=0*10; for(i=0;i<64;i++){ rin.h.dh=(unsigned char)i; rin.h.ch=(unsigned char)i; rin.h.cl=(unsigned char)i; rin.x.bx=i; int86(0*10,&rin,&rout); rin.h.ah=0*10; rin.h.al=0*1b; rin.x.cx=256; rin.x.bx=0; int86(0*10,&rin,&rout); argv++; while(--argc>0){
A Tool for Using MS Access as a Multimedia Database 97
file=fopen(*argv++,"rb"); if(file==NULL){ putc(7,stdout); break; } video=(char far*)0*A0000000L; rin.h.ah=0*0c; rin.h.bh=0; for(rin.x.dx=0;rin.x.dx<200;rin.x.dx++) for(rin.x.cx=0;rin.x.cx<320;rin.x.cx++) #ifdef USE_BIOS rin.h.al=(unsigned char)(getc(file)>>2); int86(0*10,&rin,&rout); #else *video++=(char)(getc(file)>>2); #endif } } fclose(file); getch(); } rin.h.ah=0; rin.h.al=3; int86(0*10,&rin,&rout); return 0; } ERRHAND.C #include<stdio.h> #include<stdlib.h> #include<stdarg.h> #include"errhand.h" #ifdef_STDC_ void fatal_error(char*fmt) #else #ifdef_UNIX_ void fatal_error(fmt,va_alist) char*fmt; va_dcl; #else void fatal_error(fmt)
A Tool for Using MS Access as a Multimedia Database 98
char*fmt; #endif #endif { va_list argptr; va_start(argptr,fmt); printf("Fatal Error"); vprintf(fmt,argptr); va_end(argptr); exit(-1); }
99
100