Sat Apr 20 06:59:18 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-04-20 | 2024-03-20 | 2024-02-20 | 2024-01-20 | 2023-12-20 | 2023-11-20 | 2023-10-20 | 2023-09-20 | 2023-08-20 | 2023-07-20 | 2023-06-20 | 2023-05-20 | 2023-04-20 | 2023-03-20 | 2023-02-20 | 2023-01-20 | 2022-12-20 | 2022-11-20 | 2022-10-20 | 2022-09-20 | 2022-08-20 | 2022-07-20 | 2022-06-20 | 2022-05-20 | 2022-04-20 | 2022-03-20 | 2022-02-20 | 2022-01-20 | 2021-12-20 | 2021-11-20 | 2021-10-20 | 2021-09-20 | 2021-08-20 | 2021-07-20 | 2021-06-20 | 2021-05-20 | 2021-04-20 | 2021-03-20 | 2021-02-20 | 2021-01-20 | 2020-12-20 | 2020-11-20 | 2020-10-20 | 2020-09-20 | 2020-08-20 | 2020-07-20 | 2020-06-20 | 2020-05-20 | 2020-04-20 | 2020-03-20 | 2020-02-20 | 2020-01-20 | 2019-12-20 | 2019-11-20 | 2019-10-20 | 2019-09-20 | 2019-08-20 | 2019-07-20 | 2019-06-20 | 2019-05-20 | 2019-04-20 | 2019-03-20 | 2019-02-20 | 2019-01-20 | 2018-12-20 | 2018-11-20 | 2018-10-20 | 2018-09-20 | 2018-08-20 | 2018-07-20 | 2018-06-20 | 2018-05-20 | 2018-04-20 | 2018-03-20 | 2018-02-20 | 2018-01-20 | 2017-12-20 | 2017-11-20 | 2017-10-20 | 2017-09-20 | 2017-08-20 | 2017-07-20 | 2017-06-20 | 2017-05-20 | 2017-04-20 | 2017-03-20 | 2017-02-20 | 2017-01-20 | 2016-12-20 | 2016-11-20 | 2016-10-20 | 2016-09-20 | 2016-08-20 | 2016-07-20 | 2016-06-20 | 2016-05-20 | 2016-04-20 | 2016-03-20 | 2016-02-20 | 2016-01-20 | 2015-12-20 | 2015-11-20 | 2015-10-20 | 2015-09-20 | 2015-08-20 | 2015-07-20 | 2015-06-20 | 2015-05-20 | 2015-04-20 | 2015-03-20 | 2015-02-20 | 2015-01-20 | 2014-12-20 | 2014-11-20 | 2014-10-20

Key: Value:

Key: Value:

MESSAGE
DATE 2016-12-16
FROM Ruben Safir
SUBJECT Subject: [Learn] PNG Parallel Programming problem
From learn-bounces-at-nylxs.com Fri Dec 16 03:01:32 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 164F6161312;
Fri, 16 Dec 2016 03:01:32 -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 4EFB6160E77;
Fri, 16 Dec 2016 03:01:29 -0500 (EST)
To: learn-at-nylxs.com
From: Ruben Safir
Message-ID: <7a6b3da2-7146-7c24-a7a0-197b87785334-at-mrbrklyn.com>
Date: Fri, 16 Dec 2016 03:01:28 -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="------------7B2CA79DC2F0AD9EB48129D3"
Subject: [Learn] PNG Parallel Programming problem
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.
--------------7B2CA79DC2F0AD9EB48129D3
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

I just stumbled into the fact that the quickest and easiest method
of doing the reading of the png file is with a recursive function
call. That means that creating the threads is going to be much
more straight forward than I originally anticipated. I'm attaching
the code as it is at 3AM Friday morning.... but I'm pleased
because I didn't really see it developing like this, and before
I started this program at LIU, I don't think I would have thought
up this solution.

void Image::read_chunk ( )
{
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);
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;
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
}
if(new_chunk->type() == "IEND"){
std::cout << "we have a IEND chunk " << std::endl;
//set_index(get_index() + 12 + new_chunk->length() ) ;
return;
}
set_index(get_index() + 12 + new_chunk->length() ) ;
std::cout << "Length before reading new chunk " << new_chunk->length() << std::endl;
read_chunk();
return ;
} /* ----- end of method Image::read_chunk ----- */


--
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

--------------7B2CA79DC2F0AD9EB48129D3
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;
}

--------------7B2CA79DC2F0AD9EB48129D3
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
--------------7B2CA79DC2F0AD9EB48129D3
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;
}


/***Old read chunck replaced by the one that uses CHUNKY objects below***/

// void Image::read_chunk()
// {
// unsigned char * cur = get_index();
// CHUNK * tmp = reinterpret_cast(cur);
// std::cout << std::endl << "Size of initial Chunk " << sizeof(*tmp) << std::endl;
// for(int j = 0; j<4; j++){
// std::cout << std::endl << "==> Raw Chunk Number " << j << ":\tvalue of => " << *tmp << std::endl;
// switch ( j ) {
// case 0:
// std::cout << "***LENGTH****" << std::endl;
// set_length( ntohl( static_cast(*tmp) ) );
// std::cout << "Length value => " << get_length() << std::endl;
// break;
// case 1:
// std::cout << "***TYPE****" << std::endl;
// set_type(static_cast(*tmp));
// break;
// case 2:
// {
// std::cout << "***DATA****" << std::endl;
// unsigned long int l = static_cast(get_length());
// std::cout << "buffer size should be " << get_length() << std::endl;
// uint8_t * buffer = new uint8_t[l];
// uint8_t * curarry = reinterpret_cast(tmp);
// std::cout << "buffer element size is " << sizeof(*buffer) << std::endl;
// std::cout << "buffer size is " << l << std::endl;
// for(unsigned int k = 0; k < l; k++){
// std::cout << std::endl << "BYTE NUMBER " << k << std::endl << "********" << std::endl;
// buffer[k] = curarry[k];
// std::cout << "data " << buffer[k] << std::endl;
// std::cout << "tmp " << curarry[k] << std::endl;
// }
// set_data(buffer);
// //cur = ( reinterpret_cast(tmp) );
// cur = cur + l;
// set_index(cur);
// }
// break;
// case 3:
// std::cout << "***CRC****" << std::endl;
// set_crc(static_cast(*tmp));
// break;
// default:
// std::cout << "***NOMANDSLAND****" << std::endl;
// break;
// } /* ----- end switch ----- */
//
// if(j != 2){
// //char * tmp2 = reinterpret_cast(tmp); //reading each byte
// std::cout << std::endl << "Out of switch \tSizeof Byte " << sizeof(*cur) << std::endl;
// for(int i=0; i<4; i++){
// std::cout << "Character " << i << "::" << std::endl << "\t" << *cur << std::endl;
// std::cout << "Byte " << i << "::" << std::endl << "\t" << static_cast(*cur) << std::endl;
// cur++;
// }
// std::cout<// std::cout<// //tmp++;
// //cur = ( reinterpret_cast(tmp) );
// set_index(cur);
// }
// }
// set_index(cur);
// }


void Image::read_chunk ( )
{
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);
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;
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
}
if(new_chunk->type() == "IEND"){
std::cout << "we have a IEND chunk " << std::endl;
//set_index(get_index() + 12 + new_chunk->length() ) ;
return;
}
set_index(get_index() + 12 + new_chunk->length() ) ;
std::cout << "Length before reading new chunk " << new_chunk->length() << std::endl;
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 ----- */


}


--------------7B2CA79DC2F0AD9EB48129D3
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{
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;
};

/* ==================== 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_;
};

}; /* ----- 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 ----- */

/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: get_type
*--------------------------------------------------------------------------------------
*/
// inline int32_t get_type ( )
// {
// return type;
// } /* ----- end of method Image::get_type ----- */

/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: set_type
*--------------------------------------------------------------------------------------
*/
// int32_t set_type ( int32_t value )
// {
// type = value;
// return value;
// } /* ----- end of method Image::set_type ----- */


/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: get_data
*--------------------------------------------------------------------------------------
*/
// uint8_t * get_data ( )
// {
// return data;
// } /* ----- end of method Image::get_data ----- */

/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: set_data
*--------------------------------------------------------------------------------------
*/
// void set_data ( uint8_t * value )
// {
// if(data != nullptr){
// std::cout << "LINE: " << __LINE__ << " We are deleting data" << std::endl;
// uint8_t * tmp = data;
// data = nullptr;
// delete[] tmp;
// }
//// std::cout << "LINE: " << __LINE__ << " Hello World" << std::endl;
// std::cout << "LINE: " << __LINE__ << " ASSINGING DATA FIELD TO OBJECT" << std::endl;
// data = value;//the size is determined in get_length()
// return ;
// } /* ----- end of method Image::set_data ----- */

/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: get_crc
*--------------------------------------------------------------------------------------
*/
// int32_t get_crc ( )
// {
// return crc;
// } /* ----- end of method Image::get_crc ----- */

/*
*--------------------------------------------------------------------------------------
* Class: Image
* Method: set_crc
*--------------------------------------------------------------------------------------
*/
// void set_crc ( int32_t value )
// {
// crc = value;
// return ;
// } /* ----- end of method Image::set_crc ----- */

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


/* ==================== MUTATORS ======================================= */
void read_png( const unsigned char * in = nullptr );
void read_signature();
void read_chunk();
void next_index(){
unsigned char * tmp = get_index();
set_index(++tmp);
};
void signature(){
read_signature();
};
const unsigned char * getNext( );

/* ==================== 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
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

--------------7B2CA79DC2F0AD9EB48129D3
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

--------------7B2CA79DC2F0AD9EB48129D3--

  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!