/* * VisiQuest */ /* * Copyright (c) AccuSoft Corporation, 2005. * All rights reserved. See $BOOTSTRAP/repos/license/License or run klicense. */ /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<< >>>> >>>> Driver code for mycircle >>>> >>>> Private: >>>> run_mycircle() >>>> mycircle_extra_usage_additions(); >>>> mycircle_extra_free_args(); >>>> Static: >>>> Public: >>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<< */ #include "mycircle.h" #include /*----------------------------------------------------------- | | Routine Name: run_mycircle() - Circle | | Purpose: program driver code for mycircle | | Returns: TRUE (1) on success, FALSE (0) on failure | Written By: gnemeth | Date: Apr 30, 2008 | ------------------------------------------------------------*/ int run_mycircle(void) { /*-- Put Your Code Here --*/ /*-- Put Your Code Here --*/ /* -main_variable_list */ char *lib = "mycircle_obj"; char *rtn = "main"; /* kobject in_object = NULL; */ kobject out_object = NULL; /* unsigned char *plane; */ unsigned char *res_plane; int w, h, d, t, e; int cw, ch, cd, ct, pos; int cx, cy; double dist; /* -main_variable_list_end */ /* -main_before_lib_call */ /* if ((in_object = kpds_open_input_object(clui_info->i_file)) == KOBJECT_INVALID) { kerror(lib, rtn, "Can not open input object %s.\n", clui_info->i_file); kexit(KEXIT_FAILURE); } */ if ((out_object = kpds_open_output_object(clui_info->o_file)) == KOBJECT_INVALID) { kerror(lib, rtn, "Can not open output object %s.\n", clui_info->o_file); kexit(KEXIT_FAILURE); } /* if (!kpds_copy_object(in_object, out_object)) { kerror(lib, rtn, "Can not copy input object to output object.\n"); kexit(KEXIT_FAILURE); } */ kpds_create_value( out_object ); /* kpds_set_attribute(in_object, KPDS_VALUE_DATA_TYPE, KUBYTE); */ kpds_set_attribute(out_object, KPDS_VALUE_DATA_TYPE, KUBYTE); /* kpds_get_attribute(in_object, KPDS_VALUE_SIZE, &w, &h, &d, &t, &e); */ /* ####### ALLITSD BE A MERET ATTRIBUTUMOT! ###### */ w = 256; h = 256; d = 1; t = 1; e = 1; kpds_set_attribute(out_object, KPDS_VALUE_SIZE, w, h, d, t, e); res_plane = (unsigned char *)kmalloc(w*h*sizeof(unsigned char)); if ( !res_plane) { kerror(lib, rtn, "Could not allocate memory for the image\n"); kexit(KEXIT_FAILURE); } /* -main_before_lib_call_end */ /* -main_library_call */ /* ###### HATAROZD MEG A KEP KOZEPPONTJAT! ###### */ cx = w / 2; cy = h / 2; for (ct = 0; ct < t; ct++) { kpds_set_attribute(out_object, KPDS_VALUE_POSITION, 0, 0, 0, ct, 0); kmemset(res_plane, 0, w*h*sizeof(char)); /* #### RAJZOLD A KEP KOZEPERE A KORT! ##### */ for ( ch = 0; ch < h; ch++ ) { for ( cw = 0; cw < w; cw++ ) { pos = ch * w + cw; dist = ( cw - cx ) * ( cw - cx ) + ( ch - cy ) * ( ch - cy ); dist = sqrt( dist ); if ( dist <= clui_info->radius_int ) { res_plane[pos] = 255; } else { res_plane[pos] = 0; } } } kpds_set_attribute(out_object, KPDS_VALUE_POSITION, 0, 0, 0, ct, 0); kpds_put_data(out_object, KPDS_VALUE_PLANE, (kaddr)res_plane); } /* -main_library_call_end */ /* -main_after_lib_call */ if (!kpds_set_attribute(out_object, KPDS_HISTORY, kpds_history_string())) { kerror(lib,rtn,"Unable to set history on the destination object"); kexit(KEXIT_FAILURE); } if (res_plane) kfree(res_plane); kpds_close_object(out_object); /* -main_after_lib_call_end */ return TRUE; } /*----------------------------------------------------------- | | Routine Name: mycircle_usage_additions | | Purpose: Prints usage additions in mycircle_usage routine | | Written By: gnemeth | Date: Apr 30, 2008 | ------------------------------------------------------------*/ void mycircle_extra_usage_additions(void) { /*-- Put Your Code Here --*/ return; } /*----------------------------------------------------------- | | Routine Name: mycircle_free_args | | Purpose: Frees CLUI struct allocated in mycircle_get_args() | | Input: status - The exit status for the program. | client_data - Client data needed to by the exit handler | Written By: gnemeth | Date: Apr 30, 2008 | ------------------------------------------------------------*/ /* ARGSUSED */ void mycircle_extra_free_args( kexit_status status, kaddr client_data) { /*-- Put Your Code Here --*/ return; }