static void main_window_load(Window *window){ Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); GRect weather_bounds = GRect(0,PBL_IF_ROUND_ELSE(115,105), bounds.size.w, 50); s_status_bar = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(18,5), bounds.size.w, 50)); s_time_layer = text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(43,35), bounds.size.w, 50)); //Load custom minimal font s_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_REGULAR_DOS_48)); s_font_small = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_ROBOTO_REGULAR_DOS_12)); s_weather_bitmap = gbitmap_create_with_resource(getImageId(temperature)); s_weather_icon = bitmap_layer_create(weather_bounds); window_set_background_color(s_main_window, GColorVividCerulean); //Set time text layer attributes text_layer_set_background_color(s_time_layer, GColorClear); text_layer_set_text_color(s_time_layer, GColorWhite); text_layer_set_text(s_time_layer, "00:00"); text_layer_set_font(s_time_layer, s_font); text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter); //Set status bar layer attributes text_layer_set_background_color(s_status_bar, GColorClear); text_layer_set_text_color(s_status_bar, GColorWhite); //text_layer_set_text(s_status_bar, "Battery status"); text_layer_set_font(s_status_bar, s_font_small); text_layer_set_text_alignment(s_status_bar, GTextAlignmentCenter); bitmap_layer_set_alignment(s_weather_icon, GAlignCenter); bitmap_layer_set_background_color(s_weather_icon, GColorClear); bitmap_layer_set_compositing_mode(s_weather_icon, GCompOpSet); layer_add_child(window_layer, text_layer_get_layer(s_time_layer)); layer_add_child(window_layer, text_layer_get_layer(s_status_bar)); bitmap_layer_set_bitmap(s_weather_icon, s_weather_bitmap); layer_add_child(window_layer, bitmap_layer_get_layer(s_weather_icon)); battery_handler(battery_state_service_peek()); }
void ossimNitfImageHeaderV2_0::parseStream(std::istream &in) { clearFields(); theImageBands.clear(); in.read(theType, 2); if(ossimString(theType) != "IM") { // error } in.read(theImageId, 10); in.read(theDateTime, 14); in.read(theTargetId, 17); in.read(theTitle, 80); in.read(theSecurityClassification, 1); in.read(theCodewords, 40); in.read(theControlAndHandling, 40); in.read(theReleasingInstructions, 40); in.read(theClassificationAuthority, 20); in.read(theSecurityControlNumber, 20); in.read(theSecurityDowngrade, 6); if(ossimString(theSecurityDowngrade) == "999998") { in.read(theDowngradingEvent, 40); } in.read(theEncryption, 1); in.read(theImageSource, 42); in.read(theSignificantRows, 8); in.read(theSignificantCols, 8); in.read(thePixelValueType, 3); in.read(theRepresentation, 8); in.read(theCategory, 8); in.read(theActualBitsPerPixelPerBand, 2); in.read(theJustification, 1); in.read(theCoordinateSystem, 1); if(theCoordinateSystem[0] != 'N') { in.read(theGeographicLocation, 60); } in.read(theNumberOfComments, 1); ossim_uint32 numberOfComments = ossimString(theNumberOfComments).toInt32(); if(numberOfComments > 0) { // for now let's ignore the comments about the image in.ignore(numberOfComments*80); } in.read(theCompression, 2); // check to see if there is compression ossimString temp = theCompression; if((temp != "NC") && (temp != "NM")) { // get the rate if compression exists. in.read(theCompressionRateCode, 4); } in.read(theNumberOfBands, 1); ossim_uint32 numberOfBands = ossimString(theNumberOfBands).toUInt32(); theImageBands.resize(numberOfBands); ossim_uint32 idx = 0; while(idx < numberOfBands) { theImageBands[idx] = new ossimNitfImageBandV2_0; theImageBands[idx]->parseStream(in); ++idx; } in.read(theImageSyncCode, 1); in.read(theImageMode, 1); in.read(theNumberOfBlocksPerRow, 4); in.read(theNumberOfBlocksPerCol, 4); in.read(theNumberOfPixelsPerBlockHoriz, 4); in.read(theNumberOfPixelsPerBlockVert, 4); in.read(theNumberOfBitsPerPixelPerBand, 2); in.read(theDisplayLevel, 3); in.read(theAttachmentLevel, 3); in.read(theImageLocation, 10); in.read(theImageMagnification, 4); in.read(theUserDefinedImageDataLength, 5); std::streampos userDefinedDataLen = (std::streampos)ossimString(theUserDefinedImageDataLength).toUInt32(); theTagList.clear(); ossimNitfTagInformation headerTag; std::streampos start = in.tellg(); std::streampos current = in.tellg(); if(userDefinedDataLen > 0) { in.read(theUserDefinedOverflow, 3); while((current - start) < userDefinedDataLen) { headerTag.parseStream(in); theTagList.push_back(headerTag); // in.ignore(headerTag.getTagLength()); // headerTag.clearFields(); current = in.tellg(); } } in.read(theExtendedSubheaderDataLen, 5); std::streampos extSubHeadLen = (std::streampos)ossimString(theExtendedSubheaderDataLen).toUInt32(); start = in.tellg(); current = in.tellg(); if(extSubHeadLen > 0) { in.read(theExtendedSubheaderOverflow, 3); // ossim_uint32 test = 0; while((current - start) < extSubHeadLen) { headerTag.parseStream(in); theTagList.push_back(headerTag); // test = headerTag.getTagLength()+in.tellg(); // in.ignore(headerTag.getTagLength()); // headerTag.clearFields(); current = in.tellg(); } } ossimString compressionType = theCompression; compressionType = compressionType.trim().upcase(); ossimEndian endian; ossim_uint64 locationBefore = in.tellg(); //--- // Note: "C4" added to skip over the image data mask subheader. // See MIL-STD-2500A paragraph 5.5.1.5 // // Seems like CIB data does not have. Could not find a hard and fast // rule in the specs. Need a better was to detect if this needs to be // read. (drb - 20100317) //--- if( (compressionType == "NM") || (compressionType == "M0") || (compressionType == "M3") || (compressionType == "M4") || ( (compressionType == "C4") && ( !getImageId().contains("CIB")) ) ) { in.read((char*)(&theBlockedImageDataOffset), 4); in.read((char*)(&theBlockMaskRecordLength),2); in.read((char*)(&thePadPixelMaskRecordLength), 2); in.read((char*)(&theTransparentOutputPixelCodeLength), 2); if(endian.getSystemEndianType() == OSSIM_LITTLE_ENDIAN) { endian.swap(theBlockedImageDataOffset); endian.swap(theBlockMaskRecordLength); endian.swap(thePadPixelMaskRecordLength); endian.swap(theTransparentOutputPixelCodeLength); } if(theTransparentOutputPixelCodeLength <9) { if(theTransparentOutputPixelCodeLength != 0) { ossim_uint8 padOutputPixelCode; in.read((char*)(&padOutputPixelCode), 1); thePadOutputPixelCode = padOutputPixelCode; } } else { in.read((char*)(&thePadOutputPixelCode), 2); if(endian.getSystemEndianType() == OSSIM_LITTLE_ENDIAN) { endian.swap(thePadOutputPixelCode); } // I need to add code here to check for justification when its 2 bytes // but the code length is less than 16 bits. // } if(theBlockMaskRecordLength>0) { ossim_uint32 totalNumber = 0; if((theImageMode[0] == 'S')) { totalNumber = getNumberOfBlocksPerRow()*getNumberOfBlocksPerCol()*getNumberOfBands(); } else { totalNumber = getNumberOfBlocksPerRow()*getNumberOfBlocksPerCol(); } ossim_uint32 *blockRead = new ossim_uint32[totalNumber]; ossim_uint32 idx = 0; theBlockMaskRecords.resize(totalNumber); in.read((char*)(blockRead), totalNumber*4); for(idx = 0; idx < totalNumber; ++idx) { if(endian.getSystemEndianType() == OSSIM_LITTLE_ENDIAN) { endian.swap(blockRead[idx]); } theBlockMaskRecords[idx] = blockRead[idx]; } delete [] blockRead; } if((thePadPixelMaskRecordLength > 0)|| (( (getCompressionCode().upcase() == "M3"))&& (thePadPixelMaskRecordLength == 0))) { ossim_uint32 totalNumber = 0; if((theImageMode[0] == 'S')) { totalNumber = getNumberOfBlocksPerRow()*getNumberOfBlocksPerCol()*getNumberOfBands(); } else { totalNumber = getNumberOfBlocksPerRow()*getNumberOfBlocksPerCol(); } ossim_uint32 *blockRead = new ossim_uint32[totalNumber]; ossim_uint32 idx = 0; thePadPixelMaskRecords.resize(totalNumber); in.read((char*)(blockRead), totalNumber*4); for(idx = 0; idx < totalNumber; ++idx) { if(endian.getSystemEndianType() == OSSIM_LITTLE_ENDIAN) { endian.swap(blockRead[idx]); } thePadPixelMaskRecords[idx] = blockRead[idx]; } delete [] blockRead; } } theCompressionHeader = 0; if((getCompressionCode() == "C4")|| (getCompressionCode() == "M4")) { ossimRefPtr<ossimNitfVqCompressionHeader> compressionHeader = new ossimNitfVqCompressionHeader; compressionHeader->parseStream(in); // do a check to see if the compression header is good // if( compressionHeader->getCompressionAlgorithmId()!= 1 ) { compressionHeader = 0; } theCompressionHeader = compressionHeader.get(); } ossim_uint64 delta = (ossim_uint64)in.tellg() - locationBefore; if(delta < theBlockedImageDataOffset) { in.ignore(theBlockedImageDataOffset-delta); } // // The stream should now be at the start of the data location so capture // it. // theDataLocation = in.tellg(); }