unit UD_colorimetrie; {Un dialogue pour modifier les courbes de lumière d'une trame que j'ai écrit-Denis B} {(c) écrit et concus par denis Bertin, pendant ce temps...} {Adaptatation par denis bertin à Delphi-7 (c) B&L logiciels} {Denis vient de faire le calcul pour les image bitmap (c) denis bertin le 12.09.2011} {Et comme Pascal a dit chez isagri il vont voir que c'est lui et alors ?} {Ecriture par Denis William Stéphane Bertin du module de positionnement simultanément} {De toutes les bulles qui habite au dessus de France Télecom de bourges mon domicile} interface uses wmain,windows,wbase,whelp,wformes1,messages,font_ob1,wformepa,wformebm,graphics,SyncObjs; const k_size_dim_pat = 8; k_rouge = 1; k_vert = 2; k_bleu = 3; type P_256_array = ^T_256_array; T_256_array = array [k_rouge..k_bleu,0..256] of integer; var array_diagramme:P_256_array; type trec_colorimetrie = record radio_graduation, check_synchrone, check_simultanner, radio_rouge, radio_vert, radio_bleu, radio_tous:bool; end; {t_transfert_detourage} TVisu_Spline = class(wbase.Tbutton) forme_spline_rouge,forme_spline_vert,forme_spline_bleu:wformes1.Tforme_dessin; constructor create(un_parent:TWinbase; an_id, un_id_aide:integer); procedure Setupwindow; override; procedure sous_classement; override; procedure initialisation_positif; procedure ajoute_aux_courbes(un_point_x,un_point_y:integer); procedure Visu_Set_map_mode(paintdc:hdc); procedure Get_logic_point(lparam:longint; var apt:tpoint); procedure WMPaint(var Msg: TMessage); override; procedure wmmousemove(var Msg: TMessage); override; procedure WMLButtonDown(var Msg: TMessage); override; procedure WMLButtonUp(var Msg: TMessage); override; procedure Appliquer_le_calcul; private un_select_deplacement:font_ob1.testnode; index_point_deplacer:integer; end; TColorimetrie_Dialog_Ancetre = class(Whelp.ThelpDialog) private Visu_spline:Tvisu_spline; Radio_rouge, radio_vert, radio_bleu, radio_tous:wbase.Tradiobutton; Check_graduation, check_synchrone:wbase.tcheckbox; check_simultaner:wbase.tcheckbox; Slider_de_positionnement_vertical:wbase.TscrollBar; Slider_de_positionnement_horizontal:wbase.TscrollBar; Allow_modify:boolean; constructor Create(AParent:WBase.TWindow); procedure Setupwindow; override; procedure WMCommand(var Msg: TMessage); override; procedure WMVSCROLL(var Msg: TMessage); override; procedure Simultaneted_positionnement_of_all_the_point_of_ball(posit:integer); procedure Simultaneted_positionnement_horizontal(posit:integer); end; {le dialogue d'affichage des courbes de colorimétrie (c) écrit et concus par denis Bertin, pendant ce temps...} TColorimetrie_Dialog_Trame = class(TColorimetrie_Dialog_Ancetre) constructor Create(AParent:WBase.TWindow; le_frame_buffer:wformepa.Tforme_buffer); procedure WMCommand(var Msg: TMessage); override; public un_frame_buffer:wformepa.Tforme_buffer; {un clone est néccessaire pour recommencer le calcul} clone_frame_buffer:wformepa.Tforme_buffer; end; {TColorimetrie_Dialog} TColorimetrie_Dialog_Bitmap = class(TColorimetrie_Dialog_Ancetre) constructor Create(AParent:WBase.TWindow; une_image_bitmap:wformebm.Tforme_TBitMap); procedure WMCommand(var Msg: TMessage); override; public une_image:wformebm.Tforme_TBitMap; {Un clone est aussi néccessaire ici} Un_clone_bitmap:graphics.tbitmap; end; implementation uses math,wutil,g_base,relation,haide,u_tablis,U_chercher_mes_ato,U_two_trans, deformat,wmenuk,sysutils,c_color,uregedit,U_fast_bitmap,z_open_file,k_dll; var rec_colorimetrie : Trec_colorimetrie; constructor TVisu_Spline.create(un_parent:TWinbase; an_id, un_id_aide:integer); procedure reset_param_attrib(une_courbe:wformes1.Tforme_dessin); begin une_courbe.Desactiver_tous_les_effets; end; begin forme_spline_rouge:=wformes1.Tforme_dessin.create(0,0); forme_spline_rouge.avec_bordure:=false; forme_spline_vert:=wformes1.Tforme_dessin.create(0,0); forme_spline_vert.avec_bordure:=false; forme_spline_bleu:=wformes1.Tforme_dessin.create(0,0); forme_spline_bleu.avec_bordure:=false; reset_param_attrib(forme_spline_rouge); reset_param_attrib(forme_spline_vert); reset_param_attrib(forme_spline_bleu); self.initialisation_positif; self.un_select_deplacement:=nil; inherited create(un_parent,an_id,un_id_aide); end; procedure TVisu_Spline.Setupwindow; begin inherited Setupwindow; self.initialisation_positif; invalidaterect(self.hwindow,nil,false); end; procedure TVisu_Spline.sous_classement; begin SetWindowLong(self.hwindow,GWL_WNDPROC,longint(@c_color.PROC_COLOR_REDIB)); end; {TVisu_Spline.sous_classement} procedure TVisu_Spline.initialisation_positif; var arect:trect; position_droite:integer; position_basse:integer; position_de_ce_point:tpoint; begin {(c) denis bertin} if self.hwindow=0 then exit; getclientrect(self.hwindow,arect); with arect do begin position_droite:=right-k_size_dim_pat; position_basse:=bottom-k_size_dim_pat; end; position_de_ce_point.x:=round(position_droite*1/3); position_de_ce_point.y:=round(position_basse*1/3); Self.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); position_de_ce_point.x:=round(position_droite*2/3); position_de_ce_point.y:=round(position_basse*2/3); Self.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); Self.ajoute_aux_courbes(position_droite,position_basse); forme_spline_rouge.epaisseur:=1; forme_spline_rouge.epaisseur_went:=1; forme_spline_vert.epaisseur:=1; forme_spline_vert.epaisseur_went:=1; forme_spline_bleu.epaisseur:=1; forme_spline_bleu.epaisseur_went:=1; forme_spline_rouge.couleur_pinceau:=g_base.rgb_rouge; forme_spline_vert.couleur_pinceau:=g_base.rgb_vert; forme_spline_bleu.couleur_pinceau:=g_base.rgb_bleu; forme_spline_rouge.calcul; forme_spline_vert.calcul; forme_spline_bleu.calcul; end; {TVisu_Spline.initialisation_positif} procedure TVisu_Spline.ajoute_aux_courbes(un_point_x,un_point_y:integer); begin forme_spline_rouge.elements.add(font_ob1.splinenode.create(un_point_x,un_point_y)); forme_spline_vert.elements.add(font_ob1.splinenode.create(un_point_x,un_point_y)); forme_spline_bleu.elements.add(font_ob1.splinenode.create(un_point_x,un_point_y)); end; procedure TVisu_Spline.Visu_Set_map_mode(paintdc:hdc); var arect:trect; pt_ext_viewport:tsize; dummy:tpoint; dummy_view_port_ext:tsize; begin getclientrect(self.hwindow,arect); SetMapMode(paintdc,MM_ANISOTROPIC); GetViewportExtEx(paintdc,pt_ext_viewport); SetViewPortOrgex(paintdc,0,arect.bottom,@dummy); SetViewportExtEx(paintdc,pt_ext_viewport.cx,-pt_ext_viewport.cy,@dummy_view_port_ext); end; {TVisu_Spline.Visu_Set_map_mode} procedure TVisu_Spline.WMPaint(var Msg: TMessage); var i:integer; paintdc,memdc:hdc; arect:trect; paintStruct:TPAINTSTRUCT; old_pat_size,old_dim_pat_rect:integer; aRgn,bRgn:HRgn; dot_color:tcolorRef; dw_extent:longint; grille_position:integer; apencil:hpen; un_rect_grand_plan:trect; bool_old_direction_des_vecteur:boolean; old_bitmap:hbitmap; dummy:tpoint; begin getclientrect(self.hwindow,arect); k_axe_for_visualisation:=True; paintdc:=beginpaint(hwindow,paintStruct); memdc:=CreateCompatibleDc(paintdc); old_bitmap:=Selectobject(memdc,CreateCompatibleBitmap(paintdc,arect.Right,arect.bottom)); rectangle(memdc,0,0,succ(arect.Right),succ(arect.bottom)); Self.Visu_Set_map_mode(memdc); if TColorimetrie_Dialog_Trame(parent).check_graduation.getcheck=bf_checked then begin {Afficher les graduations} apencil:=SelectObject(memdc,CreatePen(PS_DOT,1,rgb(192,192,192))); for i:=0 to 10 do with arect do begin grille_position:=round(arect.right*i/10); moveto(memdc,grille_position,0); lineto(memdc,grille_position,bottom); grille_position:=round(arect.bottom*i/10); moveto(memdc,0,grille_position); lineto(memdc,right,grille_position); end; Deleteobject(SelectObject(memdc,apencil)); end; {Afficher les graduations} aRgn:=CreateRectRgnIndirect(arect); bRgn:=selectobject(memdc,aRgn); {wutil.cross_a_rect(memdc,arect);} {trouver la couleur des points} if UD_colorimetrie.TColorimetrie_Dialog_Ancetre(parent).radio_tous.getcheck=bf_checked then dot_color:=g_base.rgb_noir; if UD_colorimetrie.TColorimetrie_Dialog_Ancetre(parent).radio_rouge.getcheck=bf_checked then dot_color:=g_base.rgb_rouge; if UD_colorimetrie.TColorimetrie_Dialog_Ancetre(parent).radio_vert.getcheck=bf_checked then dot_color:=g_base.rgb_vert; if UD_colorimetrie.TColorimetrie_Dialog_Ancetre(parent).radio_bleu.getcheck=bf_checked then dot_color:=g_base.rgb_bleu; {Mémorisation du pat} old_pat_size:=relation.dim_pat; relation.dim_pat:=k_size_dim_pat; old_dim_pat_rect:=relation.dim_pat_rect; relation.dim_pat_rect:=k_size_dim_pat; bool_old_direction_des_vecteur:=relation.rec_pref.direction_des_vecteurs; relation.rec_pref.direction_des_vecteurs:=False; {Dessin des courbes} un_rect_grand_plan:=g_base.grand_plan; if dot_color=g_base.rgb_noir then begin {les trois courbes} forme_spline_bleu.paint(memdc,un_rect_grand_plan); forme_spline_vert.paint(memdc,un_rect_grand_plan); forme_spline_rouge.paint(memdc,un_rect_grand_plan); {-les point de contrôle} forme_spline_bleu.elements.paint(memdc,0,0,g_base.rgb_bleu,math.max(forme_spline_bleu.la_largeur,forme_spline_bleu.la_hauteur)); forme_spline_vert.elements.paint(memdc,0,0,g_base.rgb_vert,math.max(forme_spline_vert.la_largeur,forme_spline_vert.la_hauteur)); forme_spline_rouge.elements.paint(memdc,0,0,g_base.rgb_rouge,math.max(forme_spline_rouge.la_largeur,forme_spline_rouge.la_hauteur)); end {les trois courbes} else begin {une des courbes} if dot_color=g_base.rgb_rouge then begin forme_spline_rouge.paint(memdc,un_rect_grand_plan); forme_spline_rouge.elements.paint(memdc,0,0,g_base.rgb_rouge,math.max(forme_spline_rouge.la_largeur,forme_spline_rouge.la_hauteur)); end; if dot_color=g_base.rgb_vert then begin forme_spline_vert.paint(memdc,un_rect_grand_plan); forme_spline_vert.elements.paint(memdc,0,0,g_base.rgb_vert,math.max(forme_spline_vert.la_largeur,forme_spline_vert.la_hauteur)); end; if dot_color=g_base.rgb_bleu then begin forme_spline_bleu.paint(memdc,un_rect_grand_plan); forme_spline_bleu.elements.paint(memdc,0,0,g_base.rgb_bleu,math.max(forme_spline_bleu.la_largeur,forme_spline_bleu.la_hauteur)); end; end; {une des courbes} relation.dim_pat_rect:=old_dim_pat_rect; relation.dim_pat:=old_pat_size; relation.rec_pref.direction_des_vecteurs:=bool_old_direction_des_vecteur; deleteobject(selectobject(memdc,brgn)); SetMapMode(memdc,MM_Text); SetViewPortOrgex(memdc,0,0,@dummy); SetViewportExtEx(memdc,0,0,@dummy); bitblt(paintdc,0,0,arect.right,arect.bottom,memdc,0,0,SRCCOPY); DeleteObject(SelectObject(Memdc,old_bitmap)); DeleteDC(memdc); endpaint(hwindow,paintStruct); k_axe_for_visualisation:=false; end; {TVisu_Spline.WMPaint} procedure TVisu_Spline.get_logic_point(lparam:longint; var apt:tpoint); var adc:hdc; begin adc:=getdc(self.hwindow); Self.Visu_Set_map_mode(adc); apt.x:=loword(lparam); apt.y:=hiword(lparam); dptolp(adc,apt,1); releasedc(self.hwindow,adc); end; {TVisu_Spline.get_logic_point} procedure TVisu_Spline.wmmousemove(var Msg: TMessage); var apt:tpoint; index:integer; node_local:font_ob1.testnode; old_pat_size:integer; arect:trect; old_deplacement:tpoint; at_elem:font_ob1.testnode; begin GetClientRect(self.hwindow,arect); apt.x:=loword(msg.lparam); apt.y:=hiword(msg.lparam); if not ptinrect(arect,apt) then exit; Get_logic_point(msg.lparam,apt); if un_select_deplacement=nil then begin {so this size is in device unit} old_pat_size:=relation.dim_pat; relation.dim_pat:=k_size_dim_pat; {recherche si le curseur est sur un des points de contrôle} node_local:=forme_spline_rouge.elements.sur_lequel(apt); if node_local=nil then node_local:=forme_spline_vert.elements.sur_lequel(apt); if node_local=nil then node_local:=forme_spline_bleu.elements.sur_lequel(apt); relation.dim_pat:=old_pat_size; {pas de déplacement du point zéro ni du point final.} if node_local<>nil then setcursor(haide.G_Cursor.Depla_fine_cursor) else SetCursor(LoadCursor(0,IDC_ARROW)); end else if un_select_deplacement<>nil then begin setcursor(haide.G_Cursor.Depla_fine_cursor); if (UD_colorimetrie.TColorimetrie_Dialog_Ancetre(parent).check_synchrone.getcheck=bf_checked) or (UD_colorimetrie.TColorimetrie_Dialog_Ancetre(parent).check_simultaner.getcheck=bf_checked) then begin old_deplacement.x:=un_select_deplacement.x; old_deplacement.y:=un_select_deplacement.y; end; if (index_point_deplacer=0) or (index_point_deplacer=3) then begin un_select_deplacement.y:=apt.y; end else begin un_select_deplacement.x:=apt.x; un_select_deplacement.y:=apt.y; end; if UD_colorimetrie.TColorimetrie_Dialog_Ancetre(parent).check_simultaner.getcheck=bf_checked then begin if forme_spline_rouge.elements.IndexOf(un_select_deplacement)<>-1 then begin index:=forme_spline_rouge.elements.IndexOf(un_select_deplacement); if (index=1) or (index=2) then begin if index=1 then at_elem:=forme_spline_rouge.elements.at(2); if index=2 then at_elem:=forme_spline_rouge.elements.at(1); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); at_elem:=forme_spline_vert.elements.at(1); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); at_elem:=forme_spline_vert.elements.at(2); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); at_elem:=forme_spline_bleu.elements.at(1); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); at_elem:=forme_spline_bleu.elements.at(2); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); end; end; if forme_spline_bleu.elements.IndexOf(un_select_deplacement)<>-1 then begin index:=forme_spline_bleu.elements.IndexOf(un_select_deplacement); if (index=1) or (index=2) then begin if index=1 then at_elem:=forme_spline_bleu.elements.at(2); if index=2 then at_elem:=forme_spline_bleu.elements.at(1); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); at_elem:=forme_spline_vert.elements.at(1); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); at_elem:=forme_spline_vert.elements.at(2); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); at_elem:=forme_spline_rouge.elements.at(1); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); at_elem:=forme_spline_rouge.elements.at(2); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); end; end; if forme_spline_vert.elements.IndexOf(un_select_deplacement)<>-1 then begin index:=forme_spline_vert.elements.IndexOf(un_select_deplacement); if (index=1) or (index=2) then begin if index=1 then at_elem:=forme_spline_vert.elements.at(2); if index=2 then at_elem:=forme_spline_vert.elements.at(1); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); at_elem:=forme_spline_bleu.elements.at(1); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); at_elem:=forme_spline_bleu.elements.at(2); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); at_elem:=forme_spline_rouge.elements.at(1); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); at_elem:=forme_spline_rouge.elements.at(2); at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); end; end; end; if UD_colorimetrie.TColorimetrie_Dialog_Ancetre(parent).check_synchrone.getcheck=bf_checked then begin if forme_spline_rouge.elements.IndexOf(un_select_deplacement)<>-1 then begin //Sur la courbe rouge; déplacer le vert et le bleu. index:=forme_spline_rouge.elements.IndexOf(un_select_deplacement); at_elem:=forme_spline_vert.elements.at(index); if at_elem<>nil then begin at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); end; at_elem:=forme_spline_bleu.elements.at(index); if at_elem<>nil then begin at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); end; end //Sur la courbe rouge; déplacer le vert et le bleu. else if forme_spline_vert.elements.IndexOf(un_select_deplacement)<>-1 then begin //Sur la courbe verte; déplacer le rouge et le bleu. index:=forme_spline_vert.elements.IndexOf(un_select_deplacement); at_elem:=forme_spline_rouge.elements.at(index); if at_elem<>nil then begin at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); end; at_elem:=forme_spline_bleu.elements.at(index); if at_elem<>nil then begin at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); end; end //Sur la courbe verte; déplacer le rouge et le bleu. else if forme_spline_bleu.elements.IndexOf(un_select_deplacement)<>-1 then begin //Sur la courbe bleu; déplacer le rouge et le vert. index:=forme_spline_bleu.elements.IndexOf(un_select_deplacement); at_elem:=forme_spline_rouge.elements.at(index); if at_elem<>nil then begin at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); end; at_elem:=forme_spline_vert.elements.at(index); if at_elem<>nil then begin at_elem.deplace(apt.x-old_deplacement.x,apt.y-old_deplacement.y,0); end; end; //Sur la courbe bleu; déplacer le rouge et le vert. end; forme_spline_rouge.calcul; forme_spline_vert.calcul; forme_spline_bleu.calcul; invalidaterect(self.hwindow,nil,true); updatewindow(self.hwindow); end; end; {TVisu_Spline.wmmousemove} procedure TVisu_Spline.WMLButtonDown(var Msg: TMessage); var apt:tpoint; old_pat_size:integer; begin Get_logic_point(msg.lparam,apt); {so this size is in device unit} old_pat_size:=relation.dim_pat; relation.dim_pat:=k_size_dim_pat; un_select_deplacement:=nil; if UD_colorimetrie.TColorimetrie_Dialog_Ancetre(parent).radio_tous.getcheck=bf_checked then begin {recherche d'un point rouge} un_select_deplacement:=forme_spline_rouge.elements.sur_lequel(apt); if un_select_deplacement<>nil then index_point_deplacer:=forme_spline_rouge.elements.indexof(un_select_deplacement) else begin {recherche d'un point vert} un_select_deplacement:=forme_spline_vert.elements.sur_lequel(apt); if un_select_deplacement<>nil then index_point_deplacer:=forme_spline_vert.elements.indexof(un_select_deplacement) else begin {recherche d'un point bleu} un_select_deplacement:=forme_spline_bleu.elements.sur_lequel(apt); if un_select_deplacement<>nil then index_point_deplacer:=forme_spline_bleu.elements.indexof(un_select_deplacement); end; end; end else if UD_colorimetrie.TColorimetrie_Dialog_Ancetre(parent).radio_rouge.getcheck=bf_checked then begin if un_select_deplacement=nil then un_select_deplacement:=forme_spline_rouge.elements.sur_lequel(apt); if un_select_deplacement<>nil then index_point_deplacer:=forme_spline_rouge.elements.indexof(un_select_deplacement); end else if UD_colorimetrie.TColorimetrie_Dialog_Ancetre(parent).radio_vert.getcheck=bf_checked then begin if un_select_deplacement=nil then un_select_deplacement:=forme_spline_vert.elements.sur_lequel(apt); if un_select_deplacement<>nil then index_point_deplacer:=forme_spline_vert.elements.indexof(un_select_deplacement); end else if UD_colorimetrie.TColorimetrie_Dialog_Ancetre(parent).radio_bleu.getcheck=bf_checked then begin if un_select_deplacement=nil then un_select_deplacement:=forme_spline_bleu.elements.sur_lequel(apt); if un_select_deplacement<>nil then index_point_deplacer:=forme_spline_bleu.elements.indexof(un_select_deplacement); end; relation.dim_pat:=old_pat_size; if un_select_deplacement<>nil then begin setcapture(self.hwindow); end; end; {TVisu_Spline.WMLButtonDown} procedure TVisu_Spline.WMLButtonUp(var Msg: TMessage); begin if un_select_deplacement=nil then exit; un_select_deplacement:=nil; ReleaseCapture; {si c'est la fin du déplacement de ce point: application du tableau à l'image} Appliquer_le_calcul; end; {TVisu_Spline.WMLButtonUp} {(c) denis bertin une méthode pour appliquer trois courbe (x,y) à une trame} procedure TVisu_Spline.Appliquer_le_calcul; type T_Tri_Max = array[k_rouge..k_bleu] of tpoint; var i,j,ithread:integer; une_trame,une_trame_clone:wformepa.Tarray_trame; une_color:tcolorref; rouge,vert,bleu:byte; uncpu:U_two_trans.TCPU; une_image_de_travail:U_fast_bitmap.TFastBitmap2; time_begin:integer; un_thread_wait:TWaitThread; modulo,posit_one,posit_two:integer; une_largeur_sa_largeur:integer; une_hauteur_sa_hauteur:integer; {$ifdef debug} apc:pc100; {$endif debug} procedure recherche_min_max(index:byte; une_courbe:wformes1.TForme_Dessin); var i,j,k:integer; deltax:real; ptmin,ptmax:T_Tri_Max; un_tabpt_ptr:u_tablis.o_tabpt; begin un_tabpt_ptr:=une_courbe.listtabpt.at(0); {min-max recherche} ptmin[index].x:=+maxint; ptmin[index].y:=+maxint; ptmax[index].x:=-maxint; ptmax[index].y:=-maxint; for i:=deformat.k_start_Tab_pt_16 to un_tabpt_ptr.npt do begin with un_tabpt_ptr.tab^[i] do begin {$ifdef debug} write('x=',x,' y=',y,' '); {$endif debug} ptmin[index].x:=min(ptmin[index].x,x); ptmin[index].y:=min(ptmin[index].y,y); ptmax[index].x:=max(ptmax[index].x,x); ptmax[index].y:=max(ptmax[index].y,y); end {with ces coordonnées} end; {for i} {initialisation à zéro} for i:=0 to 255 do begin array_diagramme^[index,i]:=0; end; {parcours de la courbe } for i:=deformat.k_start_Tab_pt_16 to un_tabpt_ptr.npt do begin with un_tabpt_ptr.tab^[i] do array_diagramme^[index,max(0,min(255,round(x/ptmax[index].x*255)))]:=y; end; {combler les zéros} for i:=1 to 255 do begin if array_diagramme^[index,i]=0 then begin {une valeur à zéro} {chercher la borne inférieur} j:=pred(i); while (array_diagramme^[index,j]=0) and (j>0) do begin dec(j); end; {chercher la borne supérieur} k:=succ(i); while (array_diagramme^[index,k]=0) and (k<255) do begin inc(k); end; if k-j=0 then begin {comme j<i et k>i impossible} deltax:=128; end {comme j<i et k>i impossible} else deltax:=(array_diagramme^[index,k]-array_diagramme^[index,j])/(k-j)+array_diagramme^[index,j]; array_diagramme^[index,i]:=round(deltax); end; {une valeur à zéro} end; {for} {variation dans l'espace 256} for i:=0 to 255 do begin array_diagramme^[index,i]:=round(array_diagramme^[index,i]/(ptmax[index].y-ptmin[index].y)*255); end; end; {recherche_min_max} begin {TVisu_Spline.Appliquer_le_calcul} if (forme_spline_rouge.listtabpt<>nil) and (forme_spline_vert.listtabpt<>nil) and (forme_spline_bleu.listtabpt<>nil) then begin Getmem(array_diagramme,sizeof(T_256_array)); recherche_min_max(k_rouge,forme_spline_rouge); recherche_min_max(k_vert,forme_spline_vert); recherche_min_max(k_bleu,forme_spline_bleu); {modifier les frames buffers} if parent.classtype=TColorimetrie_Dialog_Trame then begin for i:=0 to pred(UD_colorimetrie.TColorimetrie_Dialog_Trame(parent).un_frame_buffer.groupe.count) do begin une_trame:=UD_colorimetrie.TColorimetrie_Dialog_Trame(parent).un_frame_buffer.groupe.at(i); une_trame_clone:=UD_colorimetrie.TColorimetrie_Dialog_Trame(parent).clone_frame_buffer.groupe.at(i); {$ifdef debug} inttopchar(une_trame.nombre,apc); box(0,apc); {$endif debug} for j:=0 to pred(une_trame.nombre) do begin with une_trame_clone.dot_array^[j] do begin rouge:=array_diagramme^[k_rouge,getRvalue(color)]; vert:= array_diagramme^[k_vert,getGvalue(color)]; bleu:= array_diagramme^[k_bleu,getBvalue(color)]; end; with une_trame.dot_array^[j] do color:=RGB(rouge,vert,bleu); end; {for j} end; {for i} end else if parent.classtype=UD_colorimetrie.TColorimetrie_Dialog_Bitmap then begin UD_colorimetrie.TColorimetrie_Dialog_Bitmap(parent). une_image.BitMap.Assign(UD_colorimetrie.TColorimetrie_Dialog_Bitmap(parent).Un_clone_bitmap); une_image_de_travail.Copy(UD_colorimetrie.TColorimetrie_Dialog_Bitmap(parent).une_image.BitMap); uncpu:=U_two_trans.TCPU.Create; uncpu:=U_two_trans.TCPU.create; wformebm.nombre_de_coeur:=uncpu.Count; uncpu.Free; time_begin:=GetTickCount; une_largeur_sa_largeur:=pred(une_image_de_travail.W); une_hauteur_sa_hauteur:=pred(une_image_de_travail.H); if (wformebm.nombre_de_coeur=1) then begin for i:=0 to une_largeur_sa_largeur do begin if (i mod 100=0) and (une_largeur_sa_largeur<>0) then begin U_chercher_mes_ato.Affiche_une_ligne_de_progression((100*i) div une_largeur_sa_largeur); end; for j:=0 to une_hauteur_sa_hauteur do begin une_color:=une_image_de_travail.Getpixel(i,j); rouge:=array_diagramme^[k_rouge,getRvalue(une_color)]; vert:= array_diagramme^[k_vert,getGvalue(une_color)]; bleu:= array_diagramme^[k_bleu,getBvalue(une_color)]; une_image_de_travail.Setpixel(i,j,rgb(rouge,vert,bleu)); end; end; end else begin {Opération multo-coeur-écrit par denis-Bertin} Lock:=SyncObjs.TCriticalSection.Create; {Le Création par denis bertin d'un mutex} //Assigner la mémoire temporaire à l'image d'affichage UD_colorimetrie.TColorimetrie_Dialog_Bitmap(parent).une_image.BitMap.Assign( UD_colorimetrie.TColorimetrie_Dialog_Bitmap(parent).Un_clone_bitmap); wformebm.une_image_tres_rapide.Copy(UD_colorimetrie.TColorimetrie_Dialog_Bitmap(parent).une_image.BitMap); wformebm.ThreadsRunning:=nombre_de_coeur; un_thread_wait:=TWaitThread.create; for ithread:=1 to nombre_de_coeur do begin modulo:=une_largeur_sa_largeur div nombre_de_coeur; posit_one:=modulo*pred(ithread); {Ajouter la fin du curseur sur l'image c'est denis B} if ithread=nombre_de_coeur then posit_two:=une_largeur_sa_largeur else posit_two:=pred(modulo*ithread); with Thread_Colorimetrie.create( pred(ithread),posit_one,posit_two) do OnTerminate := ThreadDone; end; un_thread_wait.waitfor; Lock.Free; end; {Opération multi-coeur-écrit par denis-Bertin} if wmain.Status_window<>nil then wmain.Status_window.Show_time_during_of_operation(time_begin); end; invalidaterect(parent.parent.hwindow,nil,false); {false because à color draw rect is paint} FreeMem(array_diagramme,sizeof(T_256_array)); end; {listtabpt<>nil} end; {TVisu_Spline.Appliquer_le_calcul} const id_radio_rouge=501; id_radio_vert=502; id_radio_bleu=503; id_radio_tous=500; id_radio_graduation=600; id_check_synchrone=601; id_check_simultanner=602; id_bouton_positif = 400; id_bouton_negatif = 401; id_bouton_solarisation =402; id_bouton_effet_de_seuil = 403; id_bouton_Eclaircir = 404; id_bouton_Assombrir = 405; id_bouton_Eclaircir_plus = 406; id_bouton_Assombrir_moins = 407; id_bouton_Decolorer = 408; id_bouton_Accentuer = 409; id_visualisation_correction_par_spline = 300; (******************************************************************************) constructor TColorimetrie_Dialog_Ancetre.Create(AParent:WBase.TWindow); const dial_id_d_detourage=1605; id_scroll_vertical=1000; id_scroll_horizontal=1001; begin inherited create(AParent,dial_id_d_detourage,Haide.HELPId_Dialog_tramage); TransferBuffer := @rec_colorimetrie; visu_spline:=Tvisu_spline.create(self,id_visualisation_correction_par_spline,0); check_graduation:=wbase.Tradiobutton.Create(self,id_radio_graduation,6368); check_synchrone:=wbase.TcheckBox.Create(self,id_check_synchrone,6436); check_simultaner:=wbase.tcheckbox.Create(self,id_check_simultanner,6437); radio_rouge:=wbase.Tradiobutton.create(self,id_radio_rouge,6364); radio_vert:=wbase.Tradiobutton.create(self,id_radio_vert,6365); radio_bleu:=wbase.Tradiobutton.create(self,id_radio_bleu,6366); radio_tous:=wbase.Tradiobutton.create(self,id_radio_tous,6367); slider_de_positionnement_vertical:=wbase.TscrollBar.Create(self,id_scroll_vertical,0); Slider_de_positionnement_horizontal:=wbase.TscrollBar.Create(self,id_scroll_horizontal,0);; Allow_modify:=false; end; procedure TColorimetrie_Dialog_Ancetre.setupwindow; const kid_grille = 2106; kid_Colorimetrie = 2195; var apc,bpc,cpc:pc20; begin inherited setupwindow; {lecture de l'ini} if (loadstring(hinstance,kid_grille,apc,pred(sizeof(apc)))<>0) and (loadstring(hinstance,kid_Colorimetrie,bpc,pred(sizeof(bpc)))<>0) then begin {loadstring ok} uregedit.Reggetprivateprofilestring(apc,bpc,wmenuk.non,cpc,pred(sizeof(cpc))); if strcomp(cpc,wmenuk.oui)=0 then check_graduation.Check else check_graduation.Uncheck; end; slider_de_positionnement_vertical.SetRange(0,256); slider_de_positionnement_vertical.SetPosition(128); Slider_de_positionnement_horizontal.SetRange(0,256); Slider_de_positionnement_horizontal.SetPosition(128); {When this flag is set on, this could be apply} Allow_modify:=True; end; {TColorimetrie_Dialog_Ancetre.setupwindow} procedure TColorimetrie_Dialog_Ancetre.WMCommand(var Msg: TMessage); const kid_grille = 2106; kid_Colorimetrie = 2195; k_max_seuil = 5; var i:integer; arect:trect; position_droite:integer; position_basse:integer; position_de_ce_point:tpoint; anode:font_ob1.testnode; apc,bpc:pc20; procedure free_courbe; begin visu_spline.forme_spline_rouge.elements.freeall; visu_spline.forme_spline_vert.elements.freeall; visu_spline.forme_spline_bleu.elements.freeall; end; procedure termine_l_effet; begin visu_spline.forme_spline_rouge.calcul; visu_spline.forme_spline_vert.calcul; visu_spline.forme_spline_bleu.calcul; InvalidateRect(visu_spline.hwindow,nil,true); UpdateWindow(visu_spline.hwindow); visu_spline.Appliquer_le_calcul; end; begin inherited WMCommand(Msg); GetClientRect(visu_spline.hwindow,arect); with arect do begin position_droite:=right-k_size_dim_pat; position_basse:=bottom-k_size_dim_pat; end; case msg.wparam of id_radio_rouge,id_radio_vert,id_radio_bleu,id_radio_tous: invalidaterect(visu_spline.hwindow,nil,true); id_bouton_positif: begin {id_bouton_positif - (c) denis bertin} free_courbe; visu_spline.forme_spline_rouge.elements.add(pointnode.create(0,0)); visu_spline.forme_spline_vert.elements.add(pointnode.create(0,0)); visu_spline.forme_spline_bleu.elements.add(pointnode.create(0,0)); visu_spline.initialisation_positif; termine_l_effet; end; {id_bouton_positif - (c) denis bertin} id_bouton_negatif: begin {id_bouton_negatif - (c) denis bertin} free_courbe; visu_spline.forme_spline_rouge.elements.insert(pointNode.create(position_droite,0)); visu_spline.forme_spline_vert.elements.insert(pointNode.create(position_droite,0)); visu_spline.forme_spline_bleu.elements.insert(pointNode.create(position_droite,0)); position_de_ce_point.x:=round(position_droite*2/3); position_de_ce_point.y:=round(position_basse*1/3); visu_spline.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); position_de_ce_point.x:=round(position_droite*1/3); position_de_ce_point.y:=round(position_basse*2/3); visu_spline.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); with arect do visu_spline.ajoute_aux_courbes(0,position_basse); termine_l_effet; end; {id_bouton_negatif - (c) denis bertin} id_bouton_solarisation: begin {id_bouton_solarisation - (c) denis bertin} free_courbe; visu_spline.forme_spline_rouge.elements.add(pointNode.create(position_droite,0)); visu_spline.forme_spline_vert.elements.add(pointNode.create(position_droite,0)); visu_spline.forme_spline_bleu.elements.add(pointNode.create(position_droite,0)); position_de_ce_point.x:=round(position_droite*0); position_de_ce_point.y:=round(position_basse*1/3); visu_spline.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); position_de_ce_point.x:=round(position_droite*4/4); position_de_ce_point.y:=round(position_basse*2/3); visu_spline.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); with arect do visu_spline.ajoute_aux_courbes(0,position_basse); termine_l_effet; end; {id_bouton_solarisation - (c) denis bertin} id_bouton_effet_de_seuil: begin {id_bouton_effet_de_seuil (c) denis bertin} free_courbe; visu_spline.forme_spline_rouge.elements.add(pointNode.create(0,0)); visu_spline.forme_spline_vert.elements.add(pointNode.create(0,0)); visu_spline.forme_spline_bleu.elements.add(pointNode.create(0,0)); for i:=1 to k_max_seuil do begin position_de_ce_point.x:=(position_droite div k_max_seuil)*i; position_de_ce_point.y:=(position_basse div k_max_seuil)*i; visu_spline.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); if i<>k_max_seuil then begin position_de_ce_point.x:=(position_droite div k_max_seuil)*i; position_de_ce_point.y:=(position_basse div k_max_seuil)*succ(i); visu_spline.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); end; end; termine_l_effet; end; {id_bouton_effet_de_seuil (c) denis bertin} id_bouton_Eclaircir: begin {id_bouton_Eclaircir (c) denis bertin} free_courbe; visu_spline.forme_spline_rouge.elements.add(pointNode.Create(0,0)); visu_spline.forme_spline_vert.elements.add(pointNode.Create(0,0)); visu_spline.forme_spline_bleu.elements.add(pointNode.Create(0,0)); position_de_ce_point.x:=round(position_droite*1/3); position_de_ce_point.y:=round(position_basse*1/3+position_basse*1/4); visu_spline.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); position_de_ce_point.x:=round(position_droite*2/3); position_de_ce_point.y:=round(position_basse*2/3+position_basse*1/4); visu_spline.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); with arect do visu_spline.ajoute_aux_courbes(position_droite,position_basse); termine_l_effet; end; {id_bouton_Eclaircir (c) denis bertin} id_bouton_Eclaircir_plus: begin anode:=visu_spline.forme_spline_rouge.elements.at(1); anode.y:=min(position_basse,anode.y+12); anode:=visu_spline.forme_spline_vert.elements.at(1); anode.y:=min(position_basse,anode.y+12); anode:=visu_spline.forme_spline_bleu.elements.at(1); anode.y:=min(position_basse,anode.y+12); anode:=visu_spline.forme_spline_rouge.elements.at(2); anode.y:=min(position_basse,anode.y+12); anode:=visu_spline.forme_spline_vert.elements.at(2); anode.y:=min(position_basse,anode.y+12); anode:=visu_spline.forme_spline_bleu.elements.at(2); anode.y:=min(position_basse,anode.y+12); termine_l_effet; end; id_bouton_Assombrir_moins: begin anode:=visu_spline.forme_spline_rouge.elements.at(1); anode.y:=max(0,anode.y-12); anode:=visu_spline.forme_spline_vert.elements.at(1); anode.y:=max(0,anode.y-12); anode:=visu_spline.forme_spline_bleu.elements.at(1); anode.y:=max(0,anode.y-12); anode:=visu_spline.forme_spline_rouge.elements.at(2); anode.y:=max(0,anode.y-12); anode:=visu_spline.forme_spline_vert.elements.at(2); anode.y:=max(0,anode.y-12); anode:=visu_spline.forme_spline_bleu.elements.at(2); anode.y:=max(0,anode.y-12); termine_l_effet; end; id_bouton_Assombrir: begin {id_bouton_Assombrir (c) denis bertin} free_courbe; visu_spline.forme_spline_rouge.elements.add(pointNode.Create(0,0)); visu_spline.forme_spline_vert.elements.add(pointNode.Create(0,0)); visu_spline.forme_spline_bleu.elements.insert(pointNode.Create(0,0)); position_de_ce_point.x:=round(position_droite*1/3); position_de_ce_point.y:=round(position_basse*1/3-position_basse*1/4); visu_spline.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); position_de_ce_point.x:=round(position_droite*2/3); position_de_ce_point.y:=round(position_basse*2/3-position_basse*1/4); visu_spline.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); with arect do visu_spline.ajoute_aux_courbes(position_droite,position_basse); termine_l_effet; end; {id_bouton_Assombrir (c) denis bertin} id_bouton_Accentuer: begin {(c) denis bertin} free_courbe; visu_spline.forme_spline_rouge.elements.add(font_ob1.PointNode.Create(0,0)); visu_spline.forme_spline_vert.elements.add(font_ob1.PointNode.Create(0,0)); visu_spline.forme_spline_bleu.elements.add(font_ob1.PointNode.Create(0,0)); position_de_ce_point.x:=round(position_droite*1/2); position_de_ce_point.y:=round(position_basse*1/3); visu_spline.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); position_de_ce_point.x:=round(position_droite*1/2); position_de_ce_point.y:=round(position_basse*2/3); visu_spline.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); with arect do visu_spline.ajoute_aux_courbes(position_droite,position_basse); termine_l_effet; end; {id_bouton_Accentuer} id_bouton_Decolorer: begin {(c) denis bertin} free_courbe; visu_spline.forme_spline_rouge.elements.add(font_ob1.PointNode.Create(0,0)); visu_spline.forme_spline_vert.elements.add(font_ob1.PointNode.Create(0,0)); visu_spline.forme_spline_bleu.elements.add(font_ob1.PointNode.Create(0,0)); position_de_ce_point.x:=round(position_droite*1/3); position_de_ce_point.y:=round(position_basse*1/2); visu_spline.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); position_de_ce_point.x:=round(position_droite*2/3); position_de_ce_point.y:=round(position_basse*1/2); visu_spline.ajoute_aux_courbes(position_de_ce_point.x,position_de_ce_point.y); with arect do visu_spline.ajoute_aux_courbes(position_droite,position_basse); termine_l_effet; end; {id_bouton_Decolorer} id_check_synchrone: begin if check_synchrone.GetCheck=bf_checked then check_simultaner.Uncheck; end; id_check_simultanner: begin if check_simultaner.GetCheck=bf_checked then check_synchrone.Uncheck; end; id_radio_graduation: begin {id_radio_graduation} InvalidateRect(visu_spline.hwindow,nil,true); if (loadstring(hinstance,kid_grille,apc,pred(sizeof(apc)))<>0) and (loadstring(hinstance,kid_Colorimetrie,bpc,pred(sizeof(bpc)))<>0) then begin {loadstring ok} if check_graduation.getcheck=bf_checked then uregedit.Regwriteprivateprofilestring(apc,bpc,wmenuk.oui) else uregedit.Regwriteprivateprofilestring(apc,bpc,wmenuk.non); end; {loadstring ok} end; {id_radio_graduation} end; {la case} end; {TColorimetrie_Dialog_Ancetre.WMCommand} procedure TColorimetrie_Dialog_Ancetre.WMVSCROLL(var Msg: TMessage); var hwndScrollBar:hwnd; code_de_deplacement:word; begin inherited WMVSCROLL(Msg); if allow_modify then begin hwndScrollBar:=msg.lParam; if hwndScrollBar=slider_de_positionnement_vertical.hwindow then begin self.simultaneted_positionnement_of_all_the_point_of_ball( Slider_de_positionnement_vertical.GetPosition); end else if hwndScrollBar=Slider_de_positionnement_horizontal.hwindow then begin self.simultaneted_positionnement_horizontal( Slider_de_positionnement_horizontal.GetPosition); end; invalidaterect(Visu_spline.hwindow,nil,false); updatewindow(Visu_spline.hwindow); code_de_deplacement:=LOWORD(msg.wParam); case code_de_deplacement of SB_THUMBPOSITION,SB_ENDSCROLL: Visu_spline.Appliquer_le_calcul; end; end; end; {TColorimetrie_Dialog_Ancetre.WMVSCROLL} procedure TColorimetrie_Dialog_Ancetre.Simultaneted_positionnement_of_all_the_point_of_ball(posit:integer); procedure Do_it_with_the_color(une_forme:wformes1.Tforme_dessin); var i:integer; anode:font_ob1.testnode; begin for i:=1 to 2 do begin anode:=font_ob1.testnode(une_forme.elements.at(i)); if anode<>nil then anode.y:=256-posit; end; une_forme.calcul; end; {Do_it_with_the_color} begin if (radio_rouge.GetCheck=bf_checked) or (radio_tous.GetCheck=bf_checked) then Do_it_with_the_color(Visu_spline.forme_spline_rouge); if (radio_vert.GetCheck=bf_checked) or (radio_tous.GetCheck=bf_checked) then Do_it_with_the_color(Visu_spline.forme_spline_vert); if (radio_bleu.GetCheck=bf_checked) or (radio_tous.GetCheck=bf_checked) then Do_it_with_the_color(Visu_spline.forme_spline_bleu); end; {TColorimetrie_Dialog_Ancetre.simultanted_positionnement_of_all_the_point_of_ball} procedure TColorimetrie_Dialog_Ancetre.simultaneted_positionnement_horizontal(posit:integer); procedure Do_it_with_the_color(une_forme:wformes1.Tforme_dessin); var i:integer; anode:font_ob1.testnode; begin for i:=1 to 2 do begin anode:=font_ob1.testnode(une_forme.elements.at(i)); if anode<>nil then anode.x:=256-posit; end; une_forme.calcul; end; {Do_it_with_the_color} begin if (radio_rouge.GetCheck=bf_checked) or (radio_tous.GetCheck=bf_checked) then Do_it_with_the_color(Visu_spline.forme_spline_rouge); if (radio_vert.GetCheck=bf_checked) or (radio_tous.GetCheck=bf_checked) then Do_it_with_the_color(Visu_spline.forme_spline_vert); if (radio_bleu.GetCheck=bf_checked) or (radio_tous.GetCheck=bf_checked) then Do_it_with_the_color(Visu_spline.forme_spline_bleu); end; (******************************************************************************) constructor TColorimetrie_Dialog_Trame.Create(AParent:WBase.TWindow; le_frame_buffer:wformepa.Tforme_buffer); begin inherited Create(AParent); self.un_frame_buffer:=le_frame_buffer; self.clone_frame_buffer:=self.un_frame_buffer.clone; end; procedure TColorimetrie_Dialog_Trame.WMCommand(var Msg: TMessage); begin inherited WMCommand(Msg); case loword(msg.wparam) of id_cancel:self.clone_frame_buffer.clone_buffer(self.un_frame_buffer); end; end; constructor TColorimetrie_Dialog_Bitmap.Create(AParent:WBase.TWindow; une_image_bitmap:wformebm.Tforme_TBitMap); begin inherited Create(AParent); self.une_image:=une_image_bitmap; self.Un_clone_bitmap:=graphics.tbitmap.create; self.Un_clone_bitmap.assign(une_image_bitmap.BitMap); end; (******************************************************************************) procedure TColorimetrie_Dialog_Bitmap.WMCommand(var Msg: TMessage); begin inherited WMCommand(Msg); case loword(msg.wparam) of id_cancel: begin une_image.BitMap.Assign(self.Un_clone_bitmap); end; end; {case} end; {TColorimetrie_Dialog_Bitmap.WMCommand} begin with rec_colorimetrie do begin radio_graduation:=True; check_synchrone:=False; check_simultanner:=False; radio_rouge:=False; radio_vert:=False; radio_bleu:=False; radio_tous:=True; end; end.