Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstdlib>
- #include <conio.h>
- #include <iostream>
- class pixmap
- {
- private:
- char _cols;
- int _width, _height;
- char **pix_m;
- public:
- pixmap(int , int);
- uint8_t getpixel(int, int);
- void printl(int);
- };
- pixmap::pixmap(int width, int height)
- {
- _width = width;
- _height = height;
- _cols = width/8+1;
- pix_m = (char**) (calloc(height,_cols));
- for (int x =0 ; x < _cols; x++)
- {
- pix_m[x] = (char*)calloc(_cols,sizeof(char*));
- }
- printf("%d\r\n",_cols);
- }
- void pixmap::printl(int y)
- {
- int pix;
- for (int i = 0; i < _cols-1; i++)
- {
- for (int x= 0; x<8; x++)
- {
- pix = pix_m[y][i]&(0x01<<(7-x));
- printf("%d",pix!=0);
- }
- }
- int q = _width - (_cols-1)*8;
- for (int x= 0; x<q; x++)
- {
- pix = pix_m[y][_cols-1]&(0x01<<(7-x));
- printf("%d",pix!=0);
- }
- }
- /*
- uint8_t imaq::getpixel(int x , int y)
- {
- uint8_t q = (x)/8;
- uint8_t mask = 0x80 >> x%8;
- return((pix_x[q]& mask)!=0);
- }*/
- int main()
- {
- pixmap img(50,100);
- img.printl(1);
- printf("\r\n");
- /*for (int i=0 ; i <50; i++)
- {
- printf("%d",img.getpixel(i,0));
- }*/
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement