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