Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*************************************************
- * *
- * EasyBMP Cross-Platform Windows Bitmap Library *
- * *
- * Author: Paul Macklin *
- * email: macklin01@users.sourceforge.net *
- * support: http://easybmp.sourceforge.net *
- * *
- * file: EasyBMPsample.cpp *
- * date added: 03-31-2006 *
- * date modified: 12-01-2006 *
- * version: 1.06 *
- * *
- * License: BSD (revised/modified) *
- * Copyright: 2005-6 by the EasyBMP Project *
- * *
- * description: Sample application to demonstrate *dir
- * some functions and capabilities *
- * *
- *************************************************/
- //To do: Create file of 1,3,7,9 from rand(). Read file in a place relevant dot on BMP.
- #include "EasyBMP.h"
- #include<stdlib.h>
- #include<conio.h>
- using namespace std;
- int main( int argc, char* argv[] )
- {
- cout << endl
- << "Using EasyBMP Version " << _EasyBMP_Version_ << endl << endl
- << "Copyright (c) by the EasyBMP Project 2005-6" << endl
- << "WWW: http://easybmp.sourceforge.net" << endl << endl;
- BMP Text;
- Text.ReadFromFile("box0.bmp");
- // Text.ReadFromFile("EasyBMPtext.bmp");
- BMP Background;
- Background.ReadFromFile("Threes.bmp");
- // Background.ReadFromFile("EasyBMPbackground.bmp");
- BMP AnImage;
- AnImage.SetSize(640,480);
- AnImage.SetBitDepth(8);
- //AnImage.ReadFromFile("sample.bmp");
- cout << "File info:" << endl;
- cout << AnImage.TellWidth() << " x " << AnImage.TellHeight() << " at " << AnImage.TellBitDepth() << " bpp" << endl;
- cout << "colors: " << AnImage.TellNumberOfColors() << endl;
- cout << "(" << (int) AnImage(14,18)->Red << "," << (int) AnImage(14,18)->Green << "," << (int) AnImage(14,18)->Blue << "," << (int) AnImage(14,18)->Alpha << ")" << endl;
- //cout<<rand()<<"\t";
- int randDigit,i,j,ones,threes,sevens,nines;
- long nonPrimes=0;
- j=0; ones=threes=sevens=nines=0;
- while (j<480)
- {
- randDigit = rand()%10;
- //cout<<rand()%10<<"\t";
- //cout<<randDigit<<"\t";
- switch (randDigit)
- {
- case 1:
- AnImage(i,j)->Red = 255;
- AnImage(i,j)->Green = 255;
- AnImage(i,j)->Blue = 0;
- ones++;
- break;
- case 3:
- AnImage(i,j)->Red = 255;
- AnImage(i,j)->Green = 0;
- AnImage(i,j)->Blue = 0;
- threes++;
- break;
- case 7:
- AnImage(i,j)->Red = 0;
- AnImage(i,j)->Green = 255;
- AnImage(i,j)->Blue = 0;
- sevens++;
- break;
- case 9:
- //cout << "Got a nine" << endl;
- AnImage(i,j)->Red = 0;
- AnImage(i,j)->Green = 0;
- AnImage(i,j)->Blue = 255;
- nines++;
- break;
- default:
- //cout << "Not1,2" << endl;
- nonPrimes++;
- i--;
- }
- i++;
- if (i==640) {
- i=0;
- j++;
- }
- }
- AnImage.WriteToFile("copied1dots2.bmp");
- cout << "Non primes= " << nonPrimes << endl;
- cout << "Ones =" << ones;
- cout << " Threes =" << threes;
- cout << " Sevens =" << sevens;
- cout << " Nines =" << nines << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement