Thu Nov 21 23:16:19 2024
EVENTS
 FREE
SOFTWARE
INSTITUTE

POLITICS
JOBS
MEMBERS'
CORNER

MAILING
LIST

NYLXS Mailing Lists and Archives
NYLXS Members have a lot to say and share but we don't keep many secrets. Join the Hangout Mailing List and say your peice.

DATE 2016-12-01

LEARN

2024-11-21 | 2024-10-21 | 2024-09-21 | 2024-08-21 | 2024-07-21 | 2024-06-21 | 2024-05-21 | 2024-04-21 | 2024-03-21 | 2024-02-21 | 2024-01-21 | 2023-12-21 | 2023-11-21 | 2023-10-21 | 2023-09-21 | 2023-08-21 | 2023-07-21 | 2023-06-21 | 2023-05-21 | 2023-04-21 | 2023-03-21 | 2023-02-21 | 2023-01-21 | 2022-12-21 | 2022-11-21 | 2022-10-21 | 2022-09-21 | 2022-08-21 | 2022-07-21 | 2022-06-21 | 2022-05-21 | 2022-04-21 | 2022-03-21 | 2022-02-21 | 2022-01-21 | 2021-12-21 | 2021-11-21 | 2021-10-21 | 2021-09-21 | 2021-08-21 | 2021-07-21 | 2021-06-21 | 2021-05-21 | 2021-04-21 | 2021-03-21 | 2021-02-21 | 2021-01-21 | 2020-12-21 | 2020-11-21 | 2020-10-21 | 2020-09-21 | 2020-08-21 | 2020-07-21 | 2020-06-21 | 2020-05-21 | 2020-04-21 | 2020-03-21 | 2020-02-21 | 2020-01-21 | 2019-12-21 | 2019-11-21 | 2019-10-21 | 2019-09-21 | 2019-08-21 | 2019-07-21 | 2019-06-21 | 2019-05-21 | 2019-04-21 | 2019-03-21 | 2019-02-21 | 2019-01-21 | 2018-12-21 | 2018-11-21 | 2018-10-21 | 2018-09-21 | 2018-08-21 | 2018-07-21 | 2018-06-21 | 2018-05-21 | 2018-04-21 | 2018-03-21 | 2018-02-21 | 2018-01-21 | 2017-12-21 | 2017-11-21 | 2017-10-21 | 2017-09-21 | 2017-08-21 | 2017-07-21 | 2017-06-21 | 2017-05-21 | 2017-04-21 | 2017-03-21 | 2017-02-21 | 2017-01-21 | 2016-12-21 | 2016-11-21 | 2016-10-21 | 2016-09-21 | 2016-08-21 | 2016-07-21 | 2016-06-21 | 2016-05-21 | 2016-04-21 | 2016-03-21 | 2016-02-21 | 2016-01-21 | 2015-12-21 | 2015-11-21 | 2015-10-21 | 2015-09-21 | 2015-08-21 | 2015-07-21 | 2015-06-21 | 2015-05-21 | 2015-04-21 | 2015-03-21 | 2015-02-21 | 2015-01-21 | 2014-12-21 | 2014-11-21 | 2014-10-21

Key: Value:

Key: Value:

MESSAGE
DATE 2016-12-17
FROM Ruben Safir
SUBJECT Subject: [Learn] PNG threaded program
From learn-bounces-at-nylxs.com Sat Dec 17 19:01:40 2016
Return-Path:
X-Original-To: archive-at-mrbrklyn.com
Delivered-To: archive-at-mrbrklyn.com
Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82])
by mrbrklyn.com (Postfix) with ESMTP id 396DB161312;
Sat, 17 Dec 2016 19:01:40 -0500 (EST)
X-Original-To: learn-at-nylxs.com
Delivered-To: learn-at-nylxs.com
Received: from [10.0.0.62] (flatbush.mrbrklyn.com [10.0.0.62])
by mrbrklyn.com (Postfix) with ESMTP id 7EC85160E77;
Sat, 17 Dec 2016 17:48:05 -0500 (EST)
To: Samir Iabbassen
From: Ruben Safir
Message-ID: <4c6866e3-62e6-8cfc-e705-c597a05e76e5-at-mrbrklyn.com>
Date: Sat, 17 Dec 2016 17:48:05 -0500
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.5.1
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------5ED6952C672208D13FE39C20"
X-Mailman-Approved-At: Sat, 17 Dec 2016 19:01:37 -0500
Subject: [Learn] PNG threaded program
X-BeenThere: learn-at-nylxs.com
X-Mailman-Version: 2.1.17
Precedence: list
List-Id:
List-Unsubscribe: ,

List-Archive:
List-Post:
List-Help:
List-Subscribe: ,

Errors-To: learn-bounces-at-nylxs.com
Sender: "Learn"

This is a multi-part message in MIME format.
--------------5ED6952C672208D13FE39C20
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

I'm gotten quite a bit done with this, but I'm confused about some
aspect of this code, which I've attached.

Essentially, I'm creating chunks through an object CHUNKY. I tried to
make local copies of whatever I needed so that I can use them within
threads. I put mutex in order to exclusively copy indexes of the
output, and to copy sequential data from the file to the chunks, in
order to allow for the chunks to run in threads as independent objects.

I then create the thread with the CHUNKY object which calls another
thread which has CHUNKY objects. The idea was to detach the threads,
and let them copy their payloads to the "canvas" which is the combined
output, which they should be able to do independently from each other or
the calling object.

When I use it with thread.join() it works fine, but I don't think this
is optimal. When I use thread.detach(), which was my intent, it only
runs a single call, or it segfaults. I think this is because the
calling function ends maybe, before the threads can cascade? I'm not
sure. I could use more experienced feedback.

--
So many immigrant groups have swept through our town
that Brooklyn, like Atlantis, reaches mythological
proportions in the mind of the world - RI Safir 1998
http://www.mrbrklyn.com

DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
http://www.nylxs.com - Leadership Development in Free Software
http://www2.mrbrklyn.com/resources - Unpublished Archive
http://www.coinhangout.com - coins!
http://www.brooklyn-living.com

Being so tracked is for FARM ANIMALS and and extermination camps,
but incompatible with living as a free human being. -RI Safir 2013

--------------5ED6952C672208D13FE39C20
Content-Type: text/x-c++src;
name="main_png.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="main_png.cpp"

/*
* =====================================================================================
*
* Filename: main_png.cpp
*
* Description: PNG Project - main
*
* Version: 1.0
* Created: 11/30/2016 02:57:46 PM
* Revision: 1.0
* Compiler: gcc
*
* Author: Ruben Safir (mn), ruben-at-mrbrklyn.com
* Company: NYLXS Inc
*
* =====================================================================================
*/
#include
#include "png_proj.h"

int main(int argc, char **argv)
{
// const char * image_file_path = nullptr;
const char * image_file_path = "/home/ruben/images/tzfat/tzfat_dawn_blended_fused.png";
//const char * image_file_path = "/home/ruben/photo_album/images/135-red_sea_1.png";
png_proj::Image pngtestfile{image_file_path};
// pngtestfile.read_png();
std::cout << "MAIN: line:" << __LINE__ << " char * image size==>" << sizeof(image_file_path) << std::endl;
pngtestfile.read_signature();
pngtestfile.read_chunk();
// while(pngtestfile.getNext() < pngtestfile.get_end() ){
// std::cout << "Hey I am not Kosher Bird, yoy can't eat me!!" << std::endl;
// }

return EXIT_SUCCESS;
}

--------------5ED6952C672208D13FE39C20
Content-Type: text/plain; charset=UTF-8;
name="makefile"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="makefile"

Q1hYOj1nKysgCkNYWEZMQUdTOj0tV2FsbCAtZ2dkYiAgLXBnIC1wdGhyZWFkCgpMREZMQUdT
Oj0tTC91c3IvbG9jYWwvbGliL215c3FsIC1sbXlzcWxwcCAtbG15c3FsY2xpZW50IC1segoK
Cm15cG5nIDoJcG5nX3Byb2oubyBtYWluLm8KCSR7Q1hYfSAgJHtDWFhGTEFHU30gLW8gbXlw
bmcgIHBuZ19wcm9qLm8gbWFpbi5vCgptYWluLm8gOgltYWluX3BuZy5jcHAKCSR7Q1hYfSAk
e0NYWEZMQUdTfSAgLW8gbWFpbi5vIC1jIG1haW5fcG5nLmNwcAoKcG5nX3Byb2oubyA6CXBu
Z19wcm9qLmNwcAoJJHtDWFh9ICAke0NYWEZMQUdTfSAtbyBwbmdfcHJvai5vIC1jIHBuZ19w
cm9qLmNwcAoKY2xlYW4JOiAKCXJtIHBuZ19wcm9qICoubyBtYWtlLmRlcHMKCXRvdWNoICou
Y3BwICouaAoKaW5jbHVkZSBtYWtlLmRlcHMKbWFrZS5kZXBzOiAqLmNwcCA7IGdjYyAtTSAq
LmNwcCA+JEAK
--------------5ED6952C672208D13FE39C20
Content-Type: text/x-c++src;
name="png_proj.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="png_proj.cpp"

/*
* =====================================================================================
*
* Filename: png_proj.cpp
*
* Description: PNG Project
*
* Version: 1.0
* Created: 11/15/2016 12:08:44 PM
* Revision: none
* Compiler: gcc
*
* Author: Ruben Safir (mn), ruben-at-mrbrklyn.com
* Company: NYLXS Inc
*
* =====================================================================================
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "png_proj.h"

namespace png_proj{


CHUNKY::CHUNKY(unsigned char * slice ):index_{slice}, type_{4,0},
length_{ ntohl(*( reinterpret_cast(slice) ) ) }
{
index(slice + 4 ); //peel off length
t( index() );
index(index() + 4 );//peel off type
type().assign(reinterpret_cast( t() ) , 4);
data( index() );
std::cout << __FILE__ << " LINE: " << __LINE__ << " CHUNKY constructor" << std::endl;
index(index() + length() );//peel off data!
std::cout << __FILE__ << " LINE: " << __LINE__ << " CHUNKY constructor: Length " << length() << std::endl;
cr(ntohl( *(reinterpret_cast( index() ) ) ) );
}

Image::Image(const char * in):chunk_dispatch{0}
{
if(in != nullptr)
{
this->read_png(reinterpret_cast(in) );
}
}

void Image::read_png( const unsigned char * in)
{
std::streampos size;
std::ifstream file;
unsigned char * image;
if(in == nullptr)
{
file.open("/home/ruben/png_project/airplane2.PNG", std::ios::in|std::ios::binary|std::ios::ate);

}else
{
file.open(reinterpret_cast(in), std::ios::in|std::ios::binary|std::ios::ate);
}

if (file.is_open())
{
size = file.tellg();
image = new unsigned char [size];
file.seekg (0, std::ios::beg);
file.read (reinterpret_cast(image), size);
file.close();

std::cout << std::endl << "the entire file content is in memory";
std::cout << std::endl << "File Size: " << size << std::endl ;
set_length(size);
set_index(image);//set the pic buffer index
set_pic(image); //store the pic buffer
set_end( get_index() + get_length() );
set_signature(); //set the internal copy of the signature
}
else{
std::cout << std::endl << "Unable to open file";
}
}

void Image::read_signature()
{
std::cout << "OK lets read the signature!!" << std::endl;
if(get_signature() == nullptr)
{
std::cerr << "The signature hasn't been initialized yet" << std::endl;
//this shouldn't be possible because it is defined as 8 char int in the const
//and then it is filled user set_signature
return;
}
for(int i = 0;i<8;i++)
{
std::cout << "index: " << i << " value: " << *( get_signature() + i ) << std::endl;
}
std::cout << std::endl << "done reading signature" << std::endl << std::endl << std::endl;
}


void Image::read_chunk ( )
{
CHUNKY * new_chunk = set_chunk();//the chunk construction call is within
std::cout << "LINE: " << __LINE__ << " read_chunk" << std::endl;
std::cout << "Type " << new_chunk->type() << std::endl;
std::cout << "Length " << new_chunk->length() << std::endl;
std::cout << "CRC " << new_chunk->cr() << std::endl;
if(new_chunk->type() == "IHDR"){
std::cout << "we have a header chunk " << std::endl;
IHDR * head = new IHDR;
unsigned char * cur = new_chunk->data(); //NOTE:: cur is now point at the new heap for in CHNUNK and not the index for the file
head->width = ntohl( *(reinterpret_cast(cur ) ) );
cur += 4;
head->height = ntohl( *(reinterpret_cast( cur ) ) );
cur += 4;
std::cout << "Height is " << static_cast( head->height ) << " Width is " << static_cast(head->width) << std::endl;
head->depth = *( reinterpret_cast( cur ) );
std::cout << "Depth is " << static_cast(head->depth) << std::endl;
cur++;
head->color_type = *( reinterpret_cast( cur ) );
std::cout << "Color Type is " << static_cast(head->color_type) << std::endl;
cur++;
head->compress = *( reinterpret_cast( cur ) );
std::cout << "compress is => must be zero " << static_cast(head->compress) << std::endl;
cur++;
head->filter = *( reinterpret_cast( cur ) );
std::cout << "filter is " << static_cast(head->filter) << std::endl;
cur++;
head->interlace = *( reinterpret_cast( cur ) );
std::cout << "interlace is " << static_cast(head->interlace) << std::endl;
cur++;

canvas_size = static_cast(head->height) * static_cast(head->width) * blank_canvas_psize(*head);
canvas = new unsigned char[ canvas_size ];
std::cout << "Canvas made: " << static_cast(head->height) * static_cast(head->width) * blank_canvas_psize(*head) << " bytes" << std::endl;
//char tmp;
//std::cin >> tmp;
}
if(new_chunk->type() == "IDAT")
{
std::cout << "we have a IDAT chunk " << std::endl;
std::cout << "Length of IDAT " << new_chunk->length() << std::endl;
//confusion here. Do we want to create a new data array on the heap to pass through to the images for placement on canvas?
//No. Not needed. use the CHUNKY object instead. have the chunky obj schedule itself for copy to the canvas
set_canvas(*new_chunk); //SET LOCK and assign canvas index to a CHUNKY object
}
if(new_chunk->type() == "IEND"){
std::cout << "we have a IEND chunk " << std::endl;
//set_index(get_index() + 12 + new_chunk->length() ) ;
return;
}
std::thread paint( [this]{read_chunk();} );
std::cout << "Thread Paint created " << std::endl;
paint.join();
//read_chunk();
return ;
} /* ----- end of method Image::read_chunk ----- */

/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: getNext
* Description: gets the next chunk and reads the data
*--------------------------------------------------------------------------------------
*/

const unsigned char * Image::getNext ()
{
std::cout << std::endl << "getNext" << std::endl;
// next_index();
read_chunk();
const unsigned char *next = get_index();
return next;
} /* ----- end of method Image::getNext ----- */


}


--------------5ED6952C672208D13FE39C20
Content-Type: text/x-chdr;
name="png_proj.h"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="png_proj.h"

/*
* =====================================================================================
*
* Filename: png_proj.h
*
* Description: png_proj.h
*
* Version: 1.0
* Created: 11/30/2016 03:50:13 PM
* Revision: none
* Compiler: gcc
*
* Author: Ruben Safir (mn), ruben-at-mrbrklyn.com
* Company: NYLXS Inc
*
* =====================================================================================
*/

#ifndef PNGPRJ
#define PNGPRJ
#include
#include
#include

namespace png_proj{
std::mutex medco;
std::mutex master;

class thread_guard
{
public:
explicit thread_guard(std::thread& mythread):
thd{mythread}
{};
~thread_guard()
{
if(thd.joinable())
thd.join();
};
thread_guard(thread_guard const & )=delete; //prevent copy const
thread_guard& operator=(thread_guard const &)=delete;
std::thread& thd;
};

typedef uint32_t CHUNK;
struct IHDR {
int32_t width;
int32_t height;
int8_t depth;
int8_t color_type; //0 greyscale, 2 RGB, 3 Palette, 4 greyscale with alpha, 6 RGB with alpha
int8_t compress; //must be 0
int8_t filter; // must be zero
int8_t interlace;
};

/*
* =====================================================================================
* Class: CHUNKY
* Description: threaded chunk reader
* =====================================================================================
*/
class CHUNKY
{
public:

/* ==================== LIFECYCLE ======================================= */
CHUNKY (unsigned char *); /* constructor */
CHUNKY ( const CHUNKY &other ); /* copy constructor */
~CHUNKY (); /* destructor */

/* ==================== ACCESSORS ======================================= */
unsigned char *& index(){
return index_;
};
unsigned char * &index(unsigned char * pic_position){
index_ = pic_position;
return index_;
};
std::string &type(){
return type_;
};
uint32_t &length()
{
return length_;
};
uint32_t &length(uint32_t value){
return length_ = value;
};
unsigned char * & data(){
return data_;
};

unsigned char * &data(unsigned char * value){
if(value == nullptr){
std::cerr << "assigning empty chunk" << std::endl;
exit(1);
}
std::cout << __FILE__ << " LINE: " << __LINE__ << " CHUNKY:data" << std::endl;
std::cout << length() << " length" << std::endl;
if(length() != 0) //cant seem to create an array with zero elements
{
data_ = new unsigned char[length()]{0};
std::cout << __FILE__ << "LINE: " << __LINE__ << " CHUNKY:data" << std::endl;
for(unsigned int i = 0; i < length(); i++ ){
data_[i] = value[i];
return data_;
}
return data_ = new unsigned char[1];
}
std::cout << __FILE__ << "LINE: " << __LINE__ << " CHUNKY:data" << std::endl;
data_ = new unsigned char[1]{0};
std::cout << __FILE__ << "LINE: " << __LINE__ << " CHUNKY:data" << std::endl;
return data_;
};

uint32_t &cr()
{
return crc_;
};

uint32_t &cr(uint32_t value)
{
return crc_ = value;
};

unsigned char *begin()
{
return canvas_index;
};

void begin(unsigned char * value )
{
canvas_index = value;
};

unsigned char *end()
{
return next_canvas_index;
};

void end(unsigned char * value )
{
next_canvas_index = value;
};

/* ==================== MUTATORS ======================================= */

/* ==================== OPERATORS ======================================= */

const CHUNKY& operator = ( const CHUNKY &other ); /* assignment operator */

unsigned char & operator[](unsigned int value){
if(value >= length()){
std::cerr << "out of range" << std::endl;
return data_[0];
}
return data_[value];
};

protected:

private:
/*=================== Private Accessory =====================================*/
std::string &type(std::string value){
type_ = value;
return type_;
};
std::string &type(char * type_name){
type_.resize(4);
type_.assign(type_name, 4);
return type_;
};

/* ==================== DATA MEMBERS ======================================= */

unsigned char * index_;
std::string type_ ;
unsigned char t_[5];
uint32_t length_;
unsigned char * data_; //payload
uint32_t crc_;
unsigned char * t(){
return t_; //4 byte type
};
unsigned char * t(unsigned char * value){ //this is TYPE rawdata
t_[1] = value[1];
t_[2] = value[2];
t_[3] = value[3];
t_[4] = '\0';
t_[0] = value[0];

return t_;
};

unsigned char * canvas_index;
unsigned char * next_canvas_index;

}; /* ----- end of class CHUNKY ----- */


/*
* =====================================================================================
* Class: Image
* Description: Basic Image Library for PNG and Parrallel Programming Class
* =====================================================================================
*/
class Image
{
public:
/* ==================== LIFECYCLE ======================================= */
Image (); /* constructor */
Image(const char *);


/* ==================== ACCESSORS ======================================= */

/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: get_index
*--------------------------------------------------------------------------------------
*/
unsigned char * get_index ( )
{
return index;
}; /* ----- end of method Image::get_index ----- */

/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: set_index
*--------------------------------------------------------------------------------------
*/
inline void set_index ( unsigned char * value )
{
index = value;
return ;
}; /* ----- end of method Image::set_index ----- */

/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: get_pic
*--------------------------------------------------------------------------------------
*/
unsigned char * get_pic ( )
{
return pic;
}; /* ----- end of method Image::get_pic ----- */

/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: get_signature
*--------------------------------------------------------------------------------------
*/
unsigned char* get_signature()
{
return loc_signature_cpy;
}; /* ----- end of method Image::get_signature ----- */

/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: set_signature
*--------------------------------------------------------------------------------------
*/
void set_signature ()
{
unsigned char * start = loc_signature_cpy;
//loc_signature_cpy is an array int he constructor of 8 chars
// unsigned char * value = get_pic();
std::cout << "setting the signature array**" << std::endl;
std::cout << "**************************" << std::endl;
for(int i = 0; i<8; i++){
std::cout << "setting the signature" << *get_index() << std::endl;
*start = *get_index(); //this is a copy
std::cout << "signature set to =>>" << *start<< std::endl;
next_index();
start++;
}
return ;
}; /* ----- end of method Image::set_signature ----- */


/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: set_pic
*--------------------------------------------------------------------------------------
*/
void set_pic ( unsigned char * value )
{
pic = value;
return ;
}; /* ----- end of method Image::set_pic ----- */

/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: get_length
*--------------------------------------------------------------------------------------
*/
long unsigned int get_length ( )
{
return length;
}; /* ----- end of method Image::get_length ----- */

/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: set_length
*--------------------------------------------------------------------------------------
*/
long unsigned set_length ( long unsigned int value )
{
length = value;
return value ;
}; /* ----- end of method Image::set_length ----- */

unsigned char * get_end()
{
return end;
};

void set_end(unsigned char * value)
{
end = value;
};

unsigned char * canvas_index()
{
return canvas_index_;
}

void canvas_index(unsigned char * value)
{
canvas_index_ = value;

}


/* ==================== MUTATORS ======================================= */
void read_png( const unsigned char * in = nullptr );
void read_signature();
void read_chunk();
const unsigned char * getNext( );
CHUNKY * set_chunk()
{
std::lock_guard turn(master);
std::cout << "Master Lock Set" << std::endl;
std::cout << std::endl << "ENTER READ CHUNK:: LINE: " << __LINE__ << " read_chunk" << std::endl;
unsigned char *cur = reinterpret_cast( get_index() );
CHUNKY * new_chunk = new CHUNKY(cur);
set_index(get_index() + 12 + new_chunk->length() ) ;
std::cout << "Length before reading new chunk " << new_chunk->length() << std::endl;
return new_chunk;
}

CHUNKY & set_canvas(CHUNKY &yourit)
{
std::lock_guard turn(medco);
std::cout << "Medco Lock Set" << std::endl;
yourit.begin( canvas_index() );
yourit.end( canvas_index() + yourit.length() );
canvas_index( yourit.end() );
std::cout << "Lock " << std::dec << std::showbase << reinterpret_cast(yourit.begin() ) << " : " << std::dec << std::showbase << reinterpret_cast( yourit.end() )<< std::endl;
return yourit;
};

void next_index()
{
unsigned char * tmp = get_index();
set_index(++tmp);
};

void signature()
{
read_signature();
};


/* ==================== OPERATORS ======================================= */

/* ==================== DATA MEMBERS ======================================= */
protected:

private:
unsigned char * pic;
unsigned char loc_signature_cpy[8];
unsigned char * index;
unsigned char * end;
long unsigned int length; //This is the length of the entire image
// uint8_t * data = nullptr;
// int32_t type;
// int32_t crc;

unsigned char * canvas; //this is the outgoign image data
unsigned char * canvas_index_;
long int canvas_size;
long int chunk_dispatch;

int blank_canvas_psize(const IHDR &look )
{
int pixil_size;
switch (look.color_type)
{
case 0:
if(look.depth == 1)
pixil_size = 1;
if(look.depth == 2)
pixil_size = 1;
if(look.depth == 4)
pixil_size = 1;
if(look.depth == 8)
pixil_size = 1;
if(look.depth == 16)
pixil_size = 2;
break;
case 2:
if(look.depth == 8)
pixil_size = 3;
if(look.depth == 16)
pixil_size = 6;
break;
case 3:
if(look.depth == 1)
pixil_size = 3;
if(look.depth == 2)
pixil_size = 3;
if(look.depth == 4)
pixil_size = 3;
if(look.depth == 8)
pixil_size = 3;
break;
case 4:
if(look.depth == 8)
pixil_size = 4;
if(look.depth == 16)
pixil_size = 8;
break;
case 6:
if(look.depth == 8)
pixil_size = 4;
if(look.depth == 16)
pixil_size = 8;
break;
default:
std::cerr << "incorrect color type" << std::endl;
exit(EXIT_FAILURE);
}
return pixil_size;
};
}; /* ----- end of class Image ----- */


}
#endif

--------------5ED6952C672208D13FE39C20
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Learn mailing list
Learn-at-nylxs.com
http://lists.mrbrklyn.com/mailman/listinfo/learn

--------------5ED6952C672208D13FE39C20--

  1. 2016-12-01 Ruben Safir <ruben.safir-at-my.liu.edu> Subject: [Learn] Fwd: Patrolling the Dark Net,
  2. 2016-12-02 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Tutorial on threaded binary tree part 1: simple
  3. 2016-12-03 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Witner Labs
  4. 2016-12-04 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Nice lecture on Quantum Mechanics
  5. 2016-12-05 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] information access, copyright wars and DRM
  6. 2016-12-06 Christopher League <league-at-contrapunctus.net> Re: [Learn] png data format
  7. 2016-12-06 Christopher League <league-at-contrapunctus.net> Re: [Learn] png data format
  8. 2016-12-06 Christopher League <league-at-contrapunctus.net> Re: [Learn] png data format
  9. 2016-12-06 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] png data format
  10. 2016-12-06 Christopher League <league-at-contrapunctus.net> Re: [Learn] png data format
  11. 2016-12-06 Ruben Safir <ruben.safir-at-my.liu.edu> Re: [Learn] png data format
  12. 2016-12-06 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] png data format
  13. 2016-12-06 Christopher League <league-at-contrapunctus.net> Re: [Learn] png data format
  14. 2016-12-06 Ruben Safir <mrbrklyn-at-panix.com> Re: [Learn] png data format
  15. 2016-12-06 Christopher League <league-at-contrapunctus.net> Re: [Learn] png data format
  16. 2016-12-06 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] [Hangout-NYLXS] png data format
  17. 2016-12-06 John Bowler <john.cunningham.bowler-at-gmail.com> Re: [Learn] [png-mng-implement] 4 byte length storage
  18. 2016-12-06 John Bowler <john.cunningham.bowler-at-gmail.com> Re: [Learn] [png-mng-implement] 4 byte length storage
  19. 2016-12-06 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] [png-mng-implement] 4 byte length storage
  20. 2016-12-06 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Ocaml
  21. 2016-12-06 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: [luny-talk] Humble Bundle O'Reilly UNIX books
  22. 2016-12-06 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] JT's words
  23. 2016-12-06 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] png data format
  24. 2016-12-07 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: png data format
  25. 2016-12-08 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: png data format
  26. 2016-12-08 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: png data format
  27. 2016-12-08 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: png data format
  28. 2016-12-10 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] references to pointers
  29. 2016-12-10 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] C++ returning lvalue references and pointers and refs
  30. 2016-12-10 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] const puzzle and literal type arguments
  31. 2016-12-11 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: png data format
  32. 2016-12-12 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] Fwd: Re: png data format
  33. 2016-12-12 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] gene phylogienics of homonids
  34. 2016-12-13 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Bit Depth
  35. 2016-12-13 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] C++ Threads Workshop
  36. 2016-12-13 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Summer Jobs
  37. 2016-12-14 From: "Mancini, Sabin (DFS)" <Sabin.Mancini-at-dfs.ny.gov> Subject: [Learn] For Ruben ( + those in NYC Metro ) : Holiday Social Event
  38. 2016-12-14 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: [dinosaur] Ceratopsid (Centrosaurinae:
  39. 2016-12-15 Ruben Safir <ruben.safir-at-my.liu.edu> Re: [Learn] Happy Holidays
  40. 2016-12-15 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] zlib demo with vector::resize
  41. 2016-12-15 John Bowler <john.cunningham.bowler-at-gmail.com> Re: [Learn] [png-mng-implement] 4 byte length storage
  42. 2016-12-15 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: [dinosaur] Elephant bird nuclear genome fragments
  43. 2016-12-15 Christopher League <league-at-contrapunctus.net> Subject: [Learn] zlib demo with vector::resize
  44. 2016-12-16 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] zlib demo with vector::resize
  45. 2016-12-16 Christopher League <league-at-contrapunctus.net> Re: [Learn] zlib demo with vector::resize
  46. 2016-12-16 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] PNG Parallel Programming problem
  47. 2016-12-17 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] [Hangout-NYLXS] I'm sure it's a coincidence, part n+1
  48. 2016-12-17 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] irc thread on the use of object methods in threads
  49. 2016-12-17 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] PNG threaded program
  50. 2016-12-18 ruben safir <ruben-at-mrbrklyn.com> Re: [Learn] Threads and Object Methods
  51. 2016-12-18 ruben safir <ruben-at-mrbrklyn.com> Re: [Learn] Threads and Object Methods
  52. 2016-12-18 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Look C++ is a functional programming language
  53. 2016-12-19 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] C++ Threading
  54. 2016-12-19 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] C++ Threading
  55. 2016-12-19 ISOC-NY announcements <announce-at-lists.isoc-ny.org> Subject: [Learn] [isoc-ny] JOB: Telecommunications Policy Specialist -at- NTIA
  56. 2016-12-20 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] F'ing Mouse Pad
  57. 2016-12-20 mrbrklyn <mrbrklyn-at-panix.com> Subject: [Learn] Phylogenetic study worth noting
  58. 2016-12-21 Samir Iabbassen <Samir.Iabbassen-at-liu.edu> Re: [Learn] Noobdy is home
  59. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Re: [Learn] Noobdy is home
  60. 2016-12-21 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] Noobdy is home
  61. 2016-12-21 Samir Iabbassen <Samir.Iabbassen-at-liu.edu> Re: [Learn] thread concurancy
  62. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Re: [Learn] thread concurancy
  63. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: lamda's in classes
  64. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: lamda's in classes
  65. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: thread concurancy
  66. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  67. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  68. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  69. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  70. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  71. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  72. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  73. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  74. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Re: Threads and Object Methods
  75. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) thread concurancy
  76. 2016-12-21 Ruben Safir <mrbrklyn-at-panix.com> Subject: [Learn] (fwd) Threads and Object Methods
  77. 2016-12-21 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] I need help
  78. 2016-12-21 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Noobdy is home
  79. 2016-12-21 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] thread concurancy
  80. 2016-12-21 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] [Hangout-NYLXS] Marnchester by the Sea
  81. 2016-12-22 Ruben Safir <mrbrklyn-at-panix.com> Re: [Learn] [Hangout-NYLXS] And be aware you were an unexcused
  82. 2016-12-22 ruben safir <ruben-at-mrbrklyn.com> Subject: [Learn] Fwd: Re: thread concurancy
  83. 2016-12-23 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] HOPL (History of Programming Languages)
  84. 2016-12-23 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] Noobdy is home
  85. 2016-12-23 Ruben Safir <ruben-at-mrbrklyn.com> Re: [Learn] Tiny Compiler in many languages at Rosettacode.org
  86. 2016-12-25 Ruben Safir <ruben-at-mrbrklyn.com> Subject: [Learn] Google and C++
  87. 2016-12-25 Ruben Safir <ruben.safir-at-my.liu.edu> Subject: [Learn] phylogentics
  88. 2016-12-27 Samir Iabbassen <Samir.Iabbassen-at-liu.edu> Re: [Learn] thread concurancy

NYLXS are Do'ers and the first step of Doing is Joining! Join NYLXS and make a difference in your community today!