Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

jAPIimages.h

Go to the documentation of this file.
00001 
00002 //---------------------------------------------------------------------------
00003 #ifndef jAPIimagesH
00004 #define jAPIimagesH
00005 //---------------------------------------------------------------------------
00006 
00007 // Last modif : 07/03/2001 9h00
00008 
00009 #include <jpeg.hpp>
00010 #include <comctrls.hpp>
00011 #include <math.h>
00012 #include <stdio.h> 
00013 
00014 #define TBITMAP Graphics::TBitmap
00015 
00016 /*_____________________________________________________
00017 
00018  IMAGES
00019 _____________________________________________________*/
00020 
00021 int  __fastcall jCOL2word(int _color);
00022 bool __fastcall jCOL2rgb(TColor color, Byte & R, Byte & G, Byte & B);
00023 
00024 // renvoie un tableau de Byte correspondant a une image
00025 Byte ** __fastcall jIMGbmp2tab(TBITMAP * bmp)
00026 {
00027         Byte ** l_tab = new Byte*[bmp->Height];
00028         for (int i=0; i<bmp->Height; i++)
00029                 l_tab[i] = (Byte *)bmp->ScanLine[i];
00030         return l_tab;
00031 }
00032 
00033 // resize a TImage component at the Height and the Width of the Bitmap that he contains
00034 bool __fastcall jIMGresize(TImage * img);
00035 
00036 /* jIMGstretchProportionnal
00037 @description EN : Fetch the bitmap src into the bitmap dst conserving the proportions of src
00038 @description FR : Redimenssionne l'image src dans l'image dst, en conservant les proportions de src
00039 @author : JEG
00040 @param src : the image to be fetched
00041 @param dst : the image that will contains the image fetched
00042 @return        : the cadre containing the fetched image
00043 */
00044 TRect __fastcall jIMGstretchProportionnal(TBITMAP * src, TBITMAP * dst);
00045 
00046 /* jIMGstretchProportionnal
00047 @description EN : Fetch the bitmap src into the zone dstpart of the bitmap dst conserving the proportions of src
00048 @description FR : Redimenssionne l'image src dans la zone dstPart de l'image dst, en conservant les proportions de src
00049 @author : JEG
00050 @param src : the image to be fetched
00051 @param dst : the image that will contains the image fetched
00052 @param dstpart : the zone of the dst image to fetch the src image into
00053 @return        : the cadre containing the fetched image
00054 */
00055 TRect __fastcall jIMGstretchProportionnal(TBITMAP * src, TBITMAP * dst, TRect dstpart);
00056 
00057 /* jIMGzoomProportionnal
00058 @description EN : Zoom the zone srcpart of the bitmap src into the zone dstpart of the bitmap dst, conserving the propotions of src
00059 @description FR : aggrandi la zone srcpart de l'image src dans la zone dstpart de l'image dst, en conservant les proportions de src
00060 @author : JEG
00061 @param src : the image containing the zone to be zoomeds
00062 @param srcpart : the zone of the src image be zoomeds
00063 @param dst : the image that will contains the image zoomed
00064 @param dstpart : the zone of the dst image to zoom the srcpart of the image src into
00065 @return        : success or not success
00066 */
00067 bool  __fastcall jIMGzoomProportionnal(TBITMAP * src, TRect srcpart, TBITMAP * dst, TRect dstpart);
00068 
00069 // assemble et desassemble 2 image pour donner un effet de fondu ou pour compresser
00070 bool __fastcall jIMGmerge(TBITMAP * bmp1, TBITMAP * bmp2, TBITMAP * res);
00071 bool __fastcall jIMGunMerge(TBITMAP * src, TBITMAP * bmp1, TBITMAP * bmp2);
00072 
00073 // fait un fondu de la premiere image avec la deuxieme de <coeff> pourcent
00074 bool __fastcall jIMGoverlap(TBITMAP * bmp1, TBITMAP * bmp2, TBITMAP * res, int coeff=50);
00075 
00076 // fait un fondu de la premiere image SUR la deuxieme de <coeff> pourcent en laissant la transparence totale lorsquelle a été activée
00077 bool __fastcall jIMGoverlapSprite(TBITMAP * bmp, TBITMAP * sprite, int coeff, int X, int Y, int transparentColor);
00078 
00079 // fait un fondu de la premiere image avec la couleur RGB
00080 bool __fastcall jIMGfade(TBITMAP * bmp1, TBITMAP * res, TColor coul, int coeff=50);
00081 
00082 // charge & sauve un jpeg ou un bitmap
00083 bool __fastcall jIMGloadJpeg(AnsiString FileName, TBITMAP * bmp);
00084 bool __fastcall jIMGsaveJpeg(AnsiString FileName, TBITMAP * bmp);
00085 
00086 bool __fastcall jIMGloadBmp(AnsiString FileName, TBITMAP * bmp);
00087 bool __fastcall jIMGsaveBmp(AnsiString FileName, TBITMAP * bmp);
00088 
00089 bool __fastcall jIMGsaveBmpToFile(FILE * f, TBITMAP * _bmp);
00090 bool __fastcall jIMGloadBmpFromFile(FILE * f, TBITMAP * _bmp);
00091 
00092 bool __fastcall jIMGsaveJpegToFile(FILE * f, TBITMAP * _bmp);
00093 bool __fastcall jIMGloadJpegFromFile(FILE * f, TBITMAP * _bmp);
00094 
00095 bool __fastcall jIMGsaveBmpToStream(TStream * s, TBITMAP * _bmp);
00096 bool __fastcall jIMGloadBmpFromStream(TStream * s, TBITMAP * _bmp);
00097 
00098 bool __fastcall jIMGsaveJpegToStream(TStream * s, TBITMAP * _bmp);
00099 bool __fastcall jIMGloadJpegFromStream(TStream * s, TBITMAP * _bmp);
00100 
00101 
00102 // copie d'un bitmap dans un autre
00103 bool __fastcall jIMGassign(TBITMAP * dst, TBITMAP * src)
00104 {
00105         if (!(dst && src))      return false;
00106         dst->Assign(src);
00107         return true;
00108 }
00109 
00110 bool __fastcall jIMGrotate(TBITMAP * bmp1, TBITMAP * res, int Origine1x, int Origine1y, double angle);
00111 bool __fastcall jIMGrotate(TBITMAP * res, int Origine1x, int Origine1y, double angle);
00112 
00113 bool __fastcall jIMGstretchedRotate(TBITMAP * bmp, TBITMAP * res, int Origine1x, int Origine1y, double angle);
00114 bool __fastcall jIMGstretchedRotate(TBITMAP * res, int Origine1x, int Origine1y, double angle);
00115 
00116 void SuperpositionImage(TBITMAP * Bmp, TBITMAP * Bmp1, TImage * TI, int &Originex, int &Originey, int &Origine1x, int &Origine1y, double angle);
00117 void SuperpositionImage(TBITMAP * BmpRez, TBITMAP * Bmp, TBITMAP * Bmp1, TProgressBar *PrB, int &Originex, int &Originey, int &Origine1x, int &Origine1y, double angleDegree, int & DecalageX, int &DecalageY);
00118 
00119 bool __fastcall jIMGsymetryH(TBITMAP   * bmp);
00120 bool __fastcall jIMGsymetryV(TBITMAP   * bmp);
00121 bool __fastcall jIMGrotate90H(TBITMAP  * bmp);
00122 bool __fastcall jIMGrotate90AH(TBITMAP * bmp);
00123 
00124 bool __fastcall jIMGrotate90HsymH(TBITMAP  * bmp);
00125 bool __fastcall jIMGrotate90HsymV(TBITMAP  * bmp);
00126 bool __fastcall jIMGrotate90AHsymV(TBITMAP * bmp) { return jIMGrotate90HsymH(bmp);  }
00127 bool __fastcall jIMGrotate90AHsymH(TBITMAP * bmp) { return jIMGrotate90HsymV(bmp);  }
00128 
00129 bool __fastcall jIMGsymVrotate90AH(TBITMAP * bmp) { return jIMGrotate90HsymV(bmp);  }
00130 bool __fastcall jIMGsymVrotate90H(TBITMAP  * bmp) { return jIMGrotate90AHsymV(bmp); }
00131 bool __fastcall jIMGsymHrotate90AH(TBITMAP * bmp) { return jIMGrotate90HsymH(bmp);  }
00132 bool __fastcall jIMGsymHrotate90H(TBITMAP  * bmp) { return jIMGrotate90AHsymH(bmp); }
00133 
00134 bool __fastcall jIMGrotate180(TBITMAP  * bmp);
00135 bool __fastcall jIMGinvert(TBITMAP     * bmp);
00136 
00137 bool __fastcall jIMGsymetryH(TBITMAP   * Bmp1, TBITMAP * Bmp2);
00138 bool __fastcall jIMGsymetryV(TBITMAP   * Bmp1, TBITMAP * Bmp2);
00139 bool __fastcall jIMGrotate90H(TBITMAP  * Bmp1, TBITMAP * Bmp2);
00140 bool __fastcall jIMGrotate90AH(TBITMAP * Bmp1, TBITMAP * Bmp2);
00141 
00142 bool __fastcall jIMGrotate90HsymH(TBITMAP  * Bmp1, TBITMAP * Bmp2);
00143 bool __fastcall jIMGrotate90HsymV(TBITMAP  * Bmp1, TBITMAP * Bmp2);
00144 bool __fastcall jIMGrotate90AHsymV(TBITMAP * Bmp1, TBITMAP * Bmp2) { return jIMGrotate90HsymH(Bmp1, Bmp2);  }
00145 bool __fastcall jIMGrotate90AHsymH(TBITMAP * Bmp1, TBITMAP * Bmp2) { return jIMGrotate90HsymV(Bmp1, Bmp2);  }
00146 
00147 bool __fastcall jIMGsymVrotate90AH(TBITMAP * Bmp1, TBITMAP * Bmp2) { return jIMGrotate90HsymV(Bmp1, Bmp2);  }
00148 bool __fastcall jIMGsymVrotate90H(TBITMAP  * Bmp1, TBITMAP * Bmp2) { return jIMGrotate90AHsymV(Bmp1, Bmp2); }
00149 bool __fastcall jIMGsymHrotate90AH(TBITMAP * Bmp1, TBITMAP * Bmp2) { return jIMGrotate90HsymH(Bmp1, Bmp2);  }
00150 bool __fastcall jIMGsymHrotate90H(TBITMAP  * Bmp1, TBITMAP * Bmp2) { return jIMGrotate90AHsymH(Bmp1, Bmp2); }
00151 
00152 bool __fastcall jIMGrotate180(TBITMAP * Bmp1, TBITMAP * Bmp2);
00153 bool __fastcall jIMGinvert(TBITMAP * Bmp1, TBITMAP * Bmp2);
00154 
00155 bool __fastcall jIMGgrayScale(TBITMAP * bmp);
00156 bool __fastcall jIMGgrayScale(TBITMAP * Bmp1, TBITMAP * Bmp2);
00157 
00158 bool __fastcall jIMGthreshold(TBITMAP * bmp, Byte value);
00159 bool __fastcall jIMGthreshold(TBITMAP * Bmp1, TBITMAP * Bmp2, Byte value);
00160 
00161 bool __fastcall jIMGapplyFilter(int ** tab, TBITMAP * bmp1, TBITMAP * res);
00162 bool __fastcall jIMGapplyFilter(int ** tab, TBITMAP * bmp);
00163 
00164 bool __fastcall jIMGhistogram(TBITMAP * bmp, unsigned long * tab);
00165 bool __fastcall jIMGdrawHistogram(unsigned long * tab, TBITMAP * res);
00166 bool __fastcall jIMGdrawHistogram(TBITMAP * Bmp1, TBITMAP * res);
00167 
00168 bool __fastcall jIMGsquarize(TBITMAP * bmp, unsigned int size);
00169 bool __fastcall jIMGsquarize(TBITMAP * bmp1, TBITMAP * res, unsigned int size);
00170 
00171 bool __fastcall jIMGinvalidateRect(TCanvas * CV, TRect & rect);
00172 
00173 enum jBmpType {jpg, bmp};
00174 
00175 class jBitmap : public TBITMAP
00176 {
00177         public :
00178 
00179         bool __fastcall Assign(TBITMAP * bmp) { return jIMGassign(this, bmp); }
00180 
00181         bool __fastcall jMerge(TBITMAP * bmp2)
00182         {
00183                 TBITMAP * tmp = new TBITMAP();
00184                 bool res = jIMGmerge(this, bmp2, tmp);
00185                 Assign(tmp);
00186                 return res;
00187         }
00188         bool __fastcall jMerge(TBITMAP * bmp1, TBITMAP * bmp2)                          { return jIMGmerge(bmp1, bmp2, this); }
00189         bool __fastcall jUnMerge(TBITMAP * bmp1, TBITMAP * bmp2)                        { return jIMGunMerge(this, bmp1, bmp2); }
00190 
00191         bool __fastcall jOverlap(TBITMAP * bmp2, int coeff=50)
00192         {
00193                 TBITMAP * tmp = new TBITMAP();
00194                 bool res = jIMGoverlap(this, bmp2, tmp, coeff);
00195                 Assign(tmp);
00196                 return res;
00197         }
00198         bool __fastcall jOverlap(TBITMAP * bmp1, TBITMAP * bmp2, int coeff=50)          { return jIMGoverlap(bmp1, bmp2, this, coeff); }
00199         bool __fastcall jOverlapSprite(TBITMAP * sprite, int coeff, int X, int Y, int transparentColor)
00200         {
00201                 return jIMGoverlapSprite(this, sprite, coeff, X, Y, transparentColor);
00202         }
00203 
00204         bool __fastcall jFade(TColor coul, int coeff=50)
00205         {
00206                 TBITMAP * dst = new TBITMAP();
00207                 bool res = jIMGfade(this, dst, coul, coeff);
00208                 Assign(dst);
00209                 return res;
00210         }
00211         bool __fastcall jFade(TBITMAP * bmp1, TColor coul, int coeff=50)                { return jIMGfade(bmp1, this, coul, coeff); }
00212 
00213         bool __fastcall jLoadJpeg(AnsiString FileName)                                  { return jIMGloadJpeg(FileName, this); }
00214         bool __fastcall jLoadBmp(AnsiString FileName)                                   { return jIMGloadBmp(FileName, this); }
00215         bool __fastcall jSaveJpeg(AnsiString FileName)                                  { return jIMGsaveJpeg(FileName, this); }
00216         bool __fastcall jSaveBmp(AnsiString FileName)                                   { return jIMGsaveBmp(FileName, this); }
00217 
00218         bool __fastcall jLoadJpegFromFile(FILE * f)                                     { return jIMGloadJpegFromFile(f, this); }
00219         bool __fastcall jLoadBmpFromFile(FILE * f)                                      { return jIMGloadBmpFromFile(f, this); }
00220         bool __fastcall jLoadJpegFromStream(TStream * s)                                { return jIMGloadJpegFromStream(s, this); }
00221         bool __fastcall jLoadBmpFromStream(TStream * s)                                 { return jIMGloadBmpFromStream(s, this); }
00222 
00223         bool __fastcall jSaveJpegToFile(FILE * f)                                       { return jIMGsaveJpegToFile(f, this); }
00224         bool __fastcall jSaveBmpToFile(FILE * f)                                        { return jIMGsaveBmpToFile(f, this); }
00225         bool __fastcall jSaveJpegToStream(TStream * s)                                  { return jIMGsaveJpegToStream(s, this); }
00226         bool __fastcall jSaveBmpToStream(TStream * s)                                   { return jIMGsaveBmpToStream(s, this); }
00227 
00228         bool __fastcall jLoadFromFile(AnsiString FileName);
00229         bool __fastcall jSaveToFile(AnsiString FileName);
00230 
00231         bool __fastcall jLoadFromStream(TStream * _str, jBmpType _type);
00232         bool __fastcall jSaveToStream(TStream * _str, jBmpType _type);
00233 
00234         bool __fastcall jRotate90AH(TBITMAP * Bmp1)                                     { return jIMGrotate90AH(Bmp1, this); }
00235         bool __fastcall jRotate90H(TBITMAP * Bmp1)                                      { return jIMGrotate90H(Bmp1, this); }
00236         bool __fastcall jRotate90AH()                                                   { return jIMGrotate90AH(this); }
00237         bool __fastcall jRotate90H()                                                    { return jIMGrotate90H(this); }
00238 
00239         bool __fastcall jInvert()                                                       { return jIMGinvert(this); }
00240         bool __fastcall jInvert(TBITMAP * bmp)                                          { return jIMGinvert(bmp, this); }
00241         bool __fastcall jSymetryH()                                                     { return jIMGsymetryH(this); }
00242         bool __fastcall jSymetryH(TBITMAP * bmp)                                        { return jIMGsymetryH(bmp, this); }
00243         bool __fastcall jSymetryV()                                                     { return jIMGsymetryV(this); }
00244         bool __fastcall jSymetryV(TBITMAP * bmp)                                        { return jIMGsymetryV(bmp, this); }
00245         bool __fastcall jRotate180(TBITMAP * bmp)                                       { return jIMGrotate180(bmp, this); }
00246         bool __fastcall jRotate180()                                                    { return jIMGrotate180(this); }
00247 
00248         bool __fastcall jRotate90HsymH(TBITMAP * bmp)                                   { return jIMGrotate90HsymH(bmp, this); }
00249         bool __fastcall jRotate90HsymH()                                                { return jIMGrotate90HsymH(this); }
00250         bool __fastcall jRotate90HsymV(TBITMAP * bmp)                                   { return jIMGrotate90HsymV(bmp, this); }
00251         bool __fastcall jRotate90HsymV()                                                { return jIMGrotate90HsymV(this); }
00252 
00253         bool __fastcall jRotate90AHsymV(TBITMAP * bmp)                                  { return jIMGrotate90AHsymV(bmp, this); }
00254         bool __fastcall jRotate90AHsymV()                                               { return jIMGrotate90AHsymV(this); }
00255         bool __fastcall jRotate90AHsymH(TBITMAP * bmp)                                  { return jIMGrotate90AHsymH(bmp, this); }
00256         bool __fastcall jRotate90AHsymH()                                               { return jIMGrotate90AHsymH(this); }
00257 
00258         bool __fastcall jSymHrotate90AH(TBITMAP * bmp)                                  { return jIMGsymHrotate90AH(bmp, this); }
00259         bool __fastcall jSymHrotate90AH()                                               { return jIMGsymHrotate90AH(this); }
00260         bool __fastcall jSymHrotate90H(TBITMAP * bmp)                                   { return jIMGsymHrotate90H(bmp, this); }
00261         bool __fastcall jSymHrotate90H()                                                { return jIMGsymHrotate90H(this); }
00262 
00263         bool __fastcall jSymVrotate90AH(TBITMAP * bmp)                                  { return jIMGsymVrotate90AH(bmp, this); }
00264         bool __fastcall jSymVrotate90AH()                                               { return jIMGsymVrotate90AH(this); }
00265         bool __fastcall jSymVrotate90H(TBITMAP * bmp)                                   { return jIMGsymVrotate90H(bmp, this); }
00266         bool __fastcall jSymVrotate90H()                                                { return jIMGsymVrotate90H(this); }
00267 
00268         bool __fastcall jStretchedRotate(TBITMAP * res, TPoint orig, double angle)      { return jIMGstretchedRotate(res, this, orig.x, orig.y, angle); }
00269         bool __fastcall jStretchedRotate(TPoint orig, double angle)                     { return jIMGstretchedRotate(this, orig.x, orig.y, angle); }
00270 
00271         TRect __fastcall jStretchProportionnal(TBITMAP * bmp)                           { return jIMGstretchProportionnal(bmp, this); }
00272         TRect __fastcall jStretchProportionnal(TRect part, TBITMAP * bmp)               { return jIMGstretchProportionnal(bmp, this, part); }
00273         bool  __fastcall jZoomProportionnal(TBITMAP * src, TRect srcPart, TRect dstPart){ return jIMGzoomProportionnal(src, srcPart, this, dstPart); }
00274 
00275         bool __fastcall jRotate(TBITMAP * res, TPoint orig, double angle)               { return jIMGrotate(res, this, orig.x, orig.y, angle); }
00276         bool __fastcall jRotate(TPoint orig, double angle)                              { return jIMGrotate(this, orig.x, orig.y, angle); }
00277 
00278         bool __fastcall jGrayScale(TBITMAP * bmp)                                       { return jIMGgrayScale(bmp, this); }
00279         bool __fastcall jGrayScale()                                                    { return jIMGgrayScale(this); }
00280 
00281         bool __fastcall jThreshold(TBITMAP * bmp, Byte value)                           { return jIMGthreshold(bmp, this, value); }
00282         bool __fastcall jThreshold(Byte value)                                          { return jIMGthreshold(this, value); }
00283 
00284         bool __fastcall jApplyFilter(int ** tab, TBITMAP * bmp)                         { return jIMGapplyFilter(tab, bmp, this); }
00285         bool __fastcall jApplyFilter(int ** tab)                                        { return jIMGapplyFilter(tab, this); }
00286 
00287         bool __fastcall jHistogram(unsigned long * tab)                                 { return jIMGhistogram(this, tab); }
00288         bool __fastcall jDrawHistogram(unsigned long * tab)                             { return jIMGdrawHistogram(tab, this); }
00289         bool __fastcall jDrawHistogram(TBITMAP * bmp)                                   { return jIMGdrawHistogram(bmp, this); }
00290 
00291         bool __fastcall jSquarize(TBITMAP * bmp1, unsigned int size)                    { return jIMGsquarize(bmp1, this, size); }
00292         bool __fastcall jSquarize(unsigned int size)                                    { return jIMGsquarize(this, size); }
00293 
00294         bool __fastcall jDraw(TCanvas * CV, int pX, int pY);
00295         bool __fastcall jTake(TCanvas * CV, TRect & rect);
00296 
00297         bool __fastcall jCopy(TBITMAP * bmp)                                            { if (!bmp)     return false; Width = bmp->Width; Height = bmp->Height; return jTake(bmp->Canvas, TRect(0, 0, Width, Height)); } 
00298 };
00299 
00300 #endif

Generated on Sat Nov 15 10:52:34 2003 for JAPI by doxygen 1.3.4