GDIPLUS.DLL

Partagez votre expérience de PureBasic avec les autres utilisateurs.
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

Jacobus a écrit ::D Merci Denis, de te donner autant de mal pour nous tous.
J'ai hate de voir ça et de pouvoir tester toutes les possibilités de ce GDI+ en toute connaissance de cause.
au fond , je doit bien avoué que je sais toujours pas trop a quoi sert ce GDI+
:?

je veux dire , qu'est ce que cela apporte en plus ?
est-ce exploitable avec tout les systèmes ?
dans les jeux ? :D

enfin , je verrai bien lorsque ce boulot titanesque sera terminé :D
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Message par Anonyme2 »

Pour préciser, GDI+ c'est :

du 2D

permet de manipuler facilement le 2D, sans avoir à sélectionner dans le Hdc le pen, la font, la brush etc puis restitue le Hdc dans son état initial avant de retourner (c'est assez pénible avec GDI)

On peut manipuler les images facilement, beaucoup de fonctions pour mettre à l'échelle, faire une rotation angulaire, une translation, cisailler et tout cela facilement. On peut bien sur mixer ces fonctions.

Les pen disposent de plusieurs fonctions pour faire des tirets etc
On peut définir des embouts prédéfinis pour les lignes comme par exemple des embouts de flèches ou créer des embouts personnalisés

Les brush sont assez nombreuses et diverses, on peut faire des dégradés très facilement en passant la couleur de départ et celle d'arrivée. On peut aussi définir une texture pour une brush à partir d'une image etc

On peut combiner des zones ou région pour obtenir les effets voulus (exclusion, intersection, union et d'autres)

On peut faire à partir d'une image, un zoom très facilement (peu de code)

On peut dessiner des formes complexes ou simple facilement, des courbes de Bézier très facilement, des camembert, des polygones, remplir ces formes avec tous les types de brush etc

Il y a aussi la gestion de la transparence avec le mode d'interpoloation, composite, de qualité, toutes ces fonctions permettent d'agir sur le rendu final.

Le plus gros du travail reste à mon avis de bien écrire la callback pour redessiner l'ensemble correctement, il faudrait ne redessiner que ce qui est nécessaire car le traitement d'image peut être long.

C'est beaucoup plus simple d'écrire avec GDI+ que GDI, une fois la doc terminée, j'aimerais pouvoir écrire un lot de fonctions avec des noms plus courts car les noms de fonctions sont relativement long
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

ok ! merci :D
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Doute sur une constante, à votre avis ...

Message par Anonyme2 »

Voilà, je travaille sur les fonctions des images de GDI+

Une constante de GDI+ me cause un problème , c'est la constante #PixelFormat64bppPARGB

le fichier GdiPlusPixelFormats.h de microsoft donne cette définition, je ne sais pas si c'est du C ou du C++++++

Code : Tout sélectionner

#define    PixelFormatAlpha        0x00040000 // Has an alpha component
#define    PixelFormatPAlpha       0x00080000 // Pre-multiplied alpha
#define    PixelFormatExtended     0x00100000 // Extended color 16 bits/channel

#define    PixelFormat64bppPARGB      (14 | (64 << 8) | PixelFormatAlpha  | PixelFormatPAlpha | PixelFormatExtended)
j'ai converti comme ceci

Code : Tout sélectionner

  #PixelFormatAlpha     = $00040000   ; Has an alpha component
  #PixelFormatPAlpha    = $00080000   ; Pre-multiplied alpha
  #PixelFormatExtended  = $00100000   ; Extended color 16 bits/channel
  
  
  #PixelFormat64bppPARGB     =  (14 | (64 << 8) | #PixelFormatAlpha  | #PixelFormatPAlpha | #PixelFormatExtended)
un petit débug me donne une valeur décimale de 1851406 et en hexa $1C400E

j'ai fait une recherche sur internet et je trouve pour cette constante, les valeurs que je trouve ou aussi cette valeur 29622286 soit en hexa
$1C4000E c'est-à-dire avec un 0 de plus intercalé.

j'ai fait le calcul en binaire à la main et j'obtiens bien ce que je trouve avec PB

Code : Tout sélectionner

; Bin(14)        --> 000000000000000001110   ; 14
; Bin((64 << 8)) --> 000000100000000000000   ; (64 << 8) = 16384
; Bin($00040000) --> 001000000000000000000   ; $00040000
; Bin($00080000) --> 010000000000000000000   ; $00080000
; Bin($00100000) --> 100000000000000000000   ; $00100000
; ---------------------
; 111000100000000001110  --> = $1C400E = 1851406

je me demande si je me trompe quelque part surtout avec le symbole | du fichier h que j'ai interprèté comme un ou bit à bit

Votre avis ?
Gillou
Messages : 373
Inscription : sam. 28/août/2004 17:35
Localisation : Bretagne, 22
Contact :

Message par Gillou »

Si ça peux te rassurer sur le calcul

tu n'es pas le seul à trouver ce résultat, de plus

un lien sur le web (powerbasic)

avec la valeur que tu as trouvé

http://com.it-berater.org/gdiplus/nofra ... stants.htm
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Message par Anonyme2 »

Quelqu'un pourrait tester ce code sous vista pour me dire si le fichier gif créé est une séquence d'images (j'ai pas dit un gif animé) ?

Je n'arrive à sauvegarder le gif qu'avec la première image et j'ai lu sur 2 sites que c'est impossible avec GDI+ version 1.0 (donc la version XP) mais cela fonctionnerait (?) avec la version 1.1

j'ai fai un zip (1,5 Mo), il est ici

il contient les fichiers include de l'exemple + l'exemple (fichier GdipSaveAddImage_format_gif_vista.pb) et les 4 images. Il faut mettre les chemins corrects des images et des includefiles.

Le résultat devrait être un fichier gif contenant 4 images.

Voici le code de test

Code : Tout sélectionner

XIncludeFile "../../../gdiplus.pbi"

EnableExplicit

#MainWindow = 0
#ButtonGadget = 0


#Fichier1 = "../images/chien.bmp"
#Fichier2 = "../images/chat.png"
#Fichier3 = "../images/Rose_1.jpg"
#Fichier4 = "../images/chien_2.gif"


Define .l
Global *token, *image1, *image2, *image3, *image4
Global Params.EncoderParameters, erreur.l, texte$, size.q, quit.l, Valeurparametre.l, OldProc.l
Global encoderCLSID.GUID, rc.rect, rc1.rect, NomFichier$, FichierParDefaut$, status.l


Procedure GetEncoderClsid(format.s, *Clsid.CLSID)
   Protected nombre.l ; nombre d'encodeurs d'image
   Protected Size.l ; taille du tableau image encoder  en octets
   Protected *pImageCodecInfo.ImageCodecInfo ; pointeur sur le tableau image encoder
   Protected i.l, Memoire.l
   
   GdipGetImageEncodersSize(@nombre.l, @Size.l)
   If Size = 0
      ProcedureReturn - 1 ; Echec
   EndIf
   
   Memoire = AllocateMemory(Size)
   If Memoire = #Null
      ProcedureReturn - 1 ; Echec
   EndIf
   
   *pImageCodecInfo = Memoire
   GdipGetImageEncoders(nombre, Size, *pImageCodecInfo)
   
   For i = 1 To nombre
      If format = PeekS(@*pImageCodecInfo\MimeType, -1, #PB_Unicode)
         CopyMemory(@*pImageCodecInfo\clsid, *Clsid, SizeOf(CLSID))
         FreeMemory(Memoire)
         ProcedureReturn i ; Succes
      EndIf
      *pImageCodecInfo + SizeOf(ImageCodecInfo)
   Next i
   FreeMemory(Memoire)
   ProcedureReturn - 1 ; Echec
EndProcedure


Procedure GDIpCallback(window, message, wParam, lParam)
   Protected dc.l, ps.PAINTSTRUCT
   Protected *Localtoken, *Localgfx
   
   Select message
      Case #WM_CLOSE
         If *token
            GdipDisposeImage(*image1)
            GdipDisposeImage(*image2)
            GdipDisposeImage(*image3)
            GdipDisposeImage(*image4)
            GdiplusShutdown(*token)
            *token = 0
         EndIf
         OldProc = SetWindowLong_(WindowID(#MainWindow), #GWL_WNDPROC, OldProc)
         quit + 1
         ProcedureReturn 0
   EndSelect
   ProcedureReturn CallWindowProc_(OldProc, window, message, wParam, lParam)
EndProcedure


If OpenWindow(#MainWindow, 0, 0, 650, 220, "GdiPlus 1.0 - GdipSaveAddImage", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   If CreateGadgetList(WindowID(#MainWindow))
      ButtonGadget(#ButtonGadget, 10, 140, 630, 70, "Enregistrer les 4 images ci-dessus" + Chr(10) + "en un seul fichier au format gif", #PB_Button_MultiLine)
      SetGadgetFont(#ButtonGadget, LoadFont(0, "Arial", 12))
      *token = Gdiplus_New()
      If *token
         
         ; retrouve le CLSID of de l'encodeur gif
         If GetEncoderClsid("image/gif", @encoderCLSID) = -1
            ; impossible de retrouver le CLSID de l'encoder gif
            MessageRequester("Erreur", "Impossible de retrouver l'identifiant de l'encodeur" + Chr(10) + "l'application va fermer", 16)
         Else
            ; création des 4 images qui serviront à créer la séquence d'images pour le gif
            GdipLoadimageFromFile(#Fichier1, @*image1)
            GdipLoadimageFromFile(#Fichier2, @*image2)
            GdipLoadimageFromFile(#Fichier3, @*image3)
            GdipLoadimageFromFile(#Fichier4, @*image4)
            
            ; création du tableau d'encoder
            ; un EncoderParameters object est un tableau d'EncoderParameter.
            ; Initialise le seul élément du tableau pour cet exemple
            Params\Count = 1
            CopyMemory(?EncoderSaveFlag, Params\Parameter\guid, SizeOf(guid))
            With Params\Parameter[0]
               \NumberOfValues = 1
               \Type = #EncoderparameterValueTypeLong
               \Value = @Valeurparametre
            EndWith
            
            OldProc = SetWindowLong_(WindowID(#MainWindow), #GWL_WNDPROC, @GDIpCallback())
            
            ; boucle
            Repeat
               Select WaitWindowEvent()
                     
                  Case #PB_Event_Gadget
                     erreur = 0
                     ; ouvre la boite d'enregistrement des fichiers
                     NomFichier$ = SaveFileRequester("Enregistrer le fichier gif", "../images/", "gif (*.gif)|*.gif", 0)
                     If NomFichier$ = ""
                        erreur = 1
                     ElseIf GetExtensionPart(NomFichier$) = ""
                        If Right(NomFichier$, 1) = "."
                           NomFichier$ = Left(NomFichier$, Len(NomFichier$) - 1)
                        EndIf
                        NomFichier$ = GetPathPart(NomFichier$) + GetFilePart(NomFichier$) + ".gif"
                     ElseIf LCase(GetExtensionPart(NomFichier$)) <> "tif"
                        MessageRequester("Erreur", "L'extension du fichier n'est pas 'gif'", 16)
                        erreur = 1
                     EndIf
                     
                     If CheckFilename(GetFilePart(NomFichier$)) = 0
                        erreur = 1
                     EndIf
                     size = FileSize(NomFichier$)
                     If (erreur = 0) And (size > - 1)
                        texte$ = "Le fichier " + GetFilePart(NomFichier$) + " existe" + Chr(10) + Chr(10)
                        texte$ + "Voulez-vous l'écraser ?"
                        If MessageRequester("Fichier existant", texte$, #PB_MessageRequester_YesNoCancel) <> #PB_MessageRequester_Yes
                           erreur = 1
                        EndIf
                     EndIf
                     If erreur = 0
                        ; Sauvegarde la première page
                        Valeurparametre = #EncoderValueMultiFrame
                        status = GdipSaveImageToFile(*Image1, NomFichier$, @encoderCLSID, @Params)
                        If status = #Ok
                           ; la première page a été sauvegardée correctement, on sauvegarde la seconde page
                           Valeurparametre = #EncoderValueFrameDimensionTime
                           status = GdipSaveAddImage(*Image1, *Image2, Params)
                           If status = #Ok
                              ; la seconde page a été sauvegardée correctement, on sauvegarde la troisième page
                              Valeurparametre = #EncoderValueFrameDimensionTime
                              status = GdipSaveAddImage(*Image1, *Image3, Params)
                              If status = #Ok
                                 ; la troisième page a été sauvegardée correctement, on sauvegarde la quatrième page
                                 Valeurparametre = #EncoderValueFrameDimensionTime
                                 status = GdipSaveAddImage(*Image1, *Image4, Params)
                                 If status = #Ok
                                    ; la quatrième  page a été sauvegardée correctement, ferme le fichier (séquence d'image)
                                    Valeurparametre = #EncoderValueFlush
                                    status = GdipSaveAdd(*Image1, @Params)
                                    If status = #Ok
                                       size = FileSize(NomFichier$)
                                       texte$ = "Le fichier " + GetFilePart(NomFichier$) + Chr(10) + "a été enregistré avec succès" + Chr(10) + Chr(10)
                                       texte$ + "Taille du fichier : " + StrQ(size) + " octets (" + StrQ(size / 1024) + " Ko)"
                                       MessageRequester("Enregistrement du fichier gif", texte$)
                                    Else
                                       MessageRequester("Erreur", "La fonction GdipSaveAdd a échouée" + Chr(10) + " et a retournée l'erreur " + Str(status), 16)
                                    EndIf
                                 Else
                                    MessageRequester("Erreur", "La fonction GdipSaveAddImage a échouée (4ième image)" + Chr(10) + " et a retournée l'erreur " + Str(status), 16)
                                 EndIf
                              Else
                                 MessageRequester("Erreur", "La fonction GdipSaveAddImage a échouée (3ième image)" + Chr(10) + " et a retournée l'erreur " + Str(status), 16)
                              EndIf
                           Else
                              MessageRequester("Erreur", "La fonction GdipSaveAddImage a échouée (2ième image)" + Chr(10) + " et a retournée l'erreur " + Str(status), 16)
                           EndIf
                        Else
                           MessageRequester("Erreur", "La fonction GdipSaveImageToFile a échouée" + Chr(10) + " et a retournée l'erreur " + Str(status), 16)
                        EndIf
                     EndIf
                     
               EndSelect
               
            Until quit
            
         EndIf
      EndIf
      
   EndIf
   
EndIf
End


DataSection
   ;/ EncoderSaveFlag
   EncoderSaveFlag :
      Data.l $292266FC
      Data.w $AC40, $47BF
      Data.b $8C, $FC, $A8, $5B, $89, $A6, $55, $DE
EndDataSection
SFSxOI
Messages : 9
Inscription : mer. 07/mars/2007 2:46

Message par SFSxOI »

Denis;

Ne travaille pas ici sur Vista final. Seulement l'image que j'obtiens est Chien.bmp.
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Message par Anonyme2 »

thank you SFSxOI,

it's only because i don't be able to do a multi-frame gif file with GDI+ 1.0 (XP version). For me it's not really important, gif is popular but png is better

May be you will do some tries with encoder and if you can do a multi-frame gif file under Vista, send me your code :D

Take a closer look to the structures EncoderParameters and EncoderParameter i send you earlier. The structures in the zip file of this message are updated.
SFSxOI
Messages : 9
Inscription : mer. 07/mars/2007 2:46

Message par SFSxOI »

Yes, I saw the structure change, thank you very much :).

I have a question about the enumerations your using for Smoothing Mode. You have this:

Code : Tout sélectionner

Enumeration ;{ SmoothingMode GDI
  #SmoothingModeInvalid = #QualityModeInvalid
  #SmoothingModeDefault = #QualityModeDefault
  #SmoothingModeHighSpeed = #QualityModeLow
  #SmoothingModeHighQuality = #QualityModeHigh
  #SmoothingModeNone = 3
  #SmoothingModeAntiAlias = 4
EndEnumeration ;}
The MSDN says this for GDI +:

Code : Tout sélectionner

Enumeration ;{ SmoothingMode GDI +
  #SmoothingModeInvalid = #QualityModeInvalid
  #SmoothingModeDefault = #QualityModeDefault
  #SmoothingModeHighSpeed = #QualityModeLow
  #SmoothingModeHighQuality = #QualityModeHigh
  #SmoothingModeNone
  #SmoothingModeAntiAlias8x4
  #SmoothingModeAntiAlias = #SmoothingModeAntiAlias8x4
  #SmoothingModeAntiAlias8x8
EndEnumeration ;}
Which one is correct?

for the one you currently have the enumerated values would be

Code : Tout sélectionner

#QualityModeInvalid
#QualityModeDefault
#QualityModeLow
#QualityModeHigh
#SmoothingModeNone = 3
#SmoothingModeAntiAlias = 4
but for the ones from the MSDN the values would be:

Code : Tout sélectionner

#QualityModeInvalid
#QualityModeDefault
#QualityModeLow
#QualityModeHigh
0
1
#SmoothingModeAntiAlias8x4 (which is = 1)
2

where #SmoothingModeAntiAlias would not be 4 as in your enumeration but would be the value of #SmoothingModeAntiAlias8x4 which would be 1.
Then for GDI Plus would not the MSDN structure be correct?
SFSxOI
Messages : 9
Inscription : mer. 07/mars/2007 2:46

Re: Doute sur une constante, à votre avis ...

Message par SFSxOI »

Denis a écrit :Voilà, je travaille sur les fonctions des images de GDI+

Une constante de GDI+ me cause un problème , c'est la constante #PixelFormat64bppPARGB

le fichier GdiPlusPixelFormats.h de microsoft donne cette définition, je ne sais pas si c'est du C ou du C++++++

Code : Tout sélectionner

#define    PixelFormatAlpha        0x00040000 // Has an alpha component
#define    PixelFormatPAlpha       0x00080000 // Pre-multiplied alpha
#define    PixelFormatExtended     0x00100000 // Extended color 16 bits/channel

#define    PixelFormat64bppPARGB      (14 | (64 << 8) | PixelFormatAlpha  | PixelFormatPAlpha | PixelFormatExtended)
j'ai converti comme ceci

Code : Tout sélectionner

  #PixelFormatAlpha     = $00040000   ; Has an alpha component
  #PixelFormatPAlpha    = $00080000   ; Pre-multiplied alpha
  #PixelFormatExtended  = $00100000   ; Extended color 16 bits/channel
  
  
  #PixelFormat64bppPARGB     =  (14 | (64 << 8) | #PixelFormatAlpha  | #PixelFormatPAlpha | #PixelFormatExtended)
un petit débug me donne une valeur décimale de 1851406 et en hexa $1C400E

j'ai fait une recherche sur internet et je trouve pour cette constante, les valeurs que je trouve ou aussi cette valeur 29622286 soit en hexa
$1C4000E c'est-à-dire avec un 0 de plus intercalé.

j'ai fait le calcul en binaire à la main et j'obtiens bien ce que je trouve avec PB

Code : Tout sélectionner

; Bin(14)        --> 000000000000000001110   ; 14
; Bin((64 << 8)) --> 000000100000000000000   ; (64 << 8) = 16384
; Bin($00040000) --> 001000000000000000000   ; $00040000
; Bin($00080000) --> 010000000000000000000   ; $00080000
; Bin($00100000) --> 100000000000000000000   ; $00100000
; ---------------------
; 111000100000000001110  --> = $1C400E = 1851406

je me demande si je me trompe quelque part surtout avec le symbole | du fichier h que j'ai interprèté comme un ou bit à bit

Votre avis ?
#PixelFormatMax = 15

MSDN - gdiplus.h - Si soyez - #PixelFormatMax = 16 ????

quelque chose manquant ?????
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Message par Anonyme2 »

Hi SFSxOI
SFSxOI a écrit :Yes, I saw the structure change, thank you very much :).

I have a question about the enumerations your using for Smoothing Mode. You have this:

Code : Tout sélectionner

Enumeration ;{ SmoothingMode GDI
  #SmoothingModeInvalid = #QualityModeInvalid
  #SmoothingModeDefault = #QualityModeDefault
  #SmoothingModeHighSpeed = #QualityModeLow
  #SmoothingModeHighQuality = #QualityModeHigh
  #SmoothingModeNone = 3
  #SmoothingModeAntiAlias = 4
EndEnumeration ;}
The MSDN says this for GDI +:

Code : Tout sélectionner

Enumeration ;{ SmoothingMode GDI +
  #SmoothingModeInvalid = #QualityModeInvalid
  #SmoothingModeDefault = #QualityModeDefault
  #SmoothingModeHighSpeed = #QualityModeLow
  #SmoothingModeHighQuality = #QualityModeHigh
  #SmoothingModeNone
  #SmoothingModeAntiAlias8x4
  #SmoothingModeAntiAlias = #SmoothingModeAntiAlias8x4
  #SmoothingModeAntiAlias8x8
EndEnumeration ;}
Which one is correct?
both i think
MS documentation for this enumeration is here
http://msdn2.microsoft.com/en-us/library/ms534173.aspx

Take a closer look at the end of the page :
Minimum availability GDI+ 1.1
Version 1.0 and 1.1 documentation are mixed together.
I work with version 1.0 (i do not have Vista). When i get this, i use h file (version 1.0) wich is like this for this enumeration

Code : Tout sélectionner

//---------------------------------------------------------------------------
// Smoothing Mode
//---------------------------------------------------------------------------

enum SmoothingMode
{
    SmoothingModeInvalid     = QualityModeInvalid,
    SmoothingModeDefault     = QualityModeDefault,
    SmoothingModeHighSpeed   = QualityModeLow,
    SmoothingModeHighQuality = QualityModeHigh,
    SmoothingModeNone,
    SmoothingModeAntiAlias
};
QualityModeHigh is equal to 2 (enum QualityMode item for version 1.0), so SmoothingModeNone is equal to 3 and so on.

Code : Tout sélectionner

//--------------------------------------------------------------------------
// Quality mode constants
//--------------------------------------------------------------------------

enum QualityMode
{
    QualityModeInvalid   = -1,
    QualityModeDefault   = 0,
    QualityModeLow       = 1, // Best performance
    QualityModeHigh      = 2  // Best rendering quality
};


SFSxOI a écrit :for the one you currently have the enumerated values would be

Code : Tout sélectionner

#QualityModeInvalid
#QualityModeDefault
#QualityModeLow
#QualityModeHigh
#SmoothingModeNone = 3
#SmoothingModeAntiAlias = 4
but for the ones from the MSDN the values would be:

Code : Tout sélectionner

#QualityModeInvalid
#QualityModeDefault
#QualityModeLow
#QualityModeHigh
0
1
#SmoothingModeAntiAlias8x4 (which is = 1)
2

where #SmoothingModeAntiAlias would not be 4 as in your enumeration but would be the value of #SmoothingModeAntiAlias8x4 which would be 1.
Then for GDI Plus would not the MSDN structure be correct?
Where did you find those values ?

Code : Tout sélectionner

#QualityModeInvalid
#QualityModeDefault
#QualityModeLow
#QualityModeHigh
0
1
#SmoothingModeAntiAlias8x4 (which is = 1)
2
I don't think that #QualityModeHigh has change with version 1.1 because the new values are added at the end of enumeration
I don't find file GdiPlusEnums.h for version 1.1
For me, the values for version 1.1 are :

Code : Tout sélectionner

  #SmoothingModeInvalid = #QualityModeInvalid
  #SmoothingModeDefault = #QualityModeDefault
  #SmoothingModeHighSpeed = #QualityModeLow
  #SmoothingModeHighQuality = #QualityModeHigh
  #SmoothingModeNone = 3
  #SmoothingModeAntiAlias8x4 = 4
  #SmoothingModeAntiAlias = #SmoothingModeAntiAlias8x4 ; = 4
  #SmoothingModeAntiAlias8x8 = 5
some web site give a value of 4 for #SmoothingModeAntiAlias8x4
http://jsourcery.com/output/eclipse/3.1 ... -373454319
http://www.activevb.de/tipps/vb6tipps/tipp0658.html

Denis
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Re: Doute sur une constante, à votre avis ...

Message par Anonyme2 »

SFSxOI a écrit : #PixelFormatMax = 15

MSDN - gdiplus.h - Si soyez - #PixelFormatMax = 16 ????

quelque chose manquant ?????
SFSxOI, I didn't find #PixelFormatMax in gdiplus.h, but only in GdiPlusPixelFormats.h

here are all Pixel values and 15 is right for #PixelFormatMax.

Code : Tout sélectionner

// In-memory pixel data formats:
// bits 0-7 = format index
// bits 8-15 = pixel size (in bits)
// bits 16-23 = flags
// bits 24-31 = reserved

typedef INT PixelFormat;

#define    PixelFormatIndexed      0x00010000 // Indexes into a palette
#define    PixelFormatGDI          0x00020000 // Is a GDI-supported format
#define    PixelFormatAlpha        0x00040000 // Has an alpha component
#define    PixelFormatPAlpha       0x00080000 // Pre-multiplied alpha
#define    PixelFormatExtended     0x00100000 // Extended color 16 bits/channel
#define    PixelFormatCanonical    0x00200000 

#define    PixelFormatUndefined       0
#define    PixelFormatDontCare        0

#define    PixelFormat1bppIndexed     (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define    PixelFormat4bppIndexed     (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define    PixelFormat8bppIndexed     (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define    PixelFormat16bppGrayScale  (4 | (16 << 8) | PixelFormatExtended)
#define    PixelFormat16bppRGB555     (5 | (16 << 8) | PixelFormatGDI)
#define    PixelFormat16bppRGB565     (6 | (16 << 8) | PixelFormatGDI)
#define    PixelFormat16bppARGB1555   (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI)
#define    PixelFormat24bppRGB        (8 | (24 << 8) | PixelFormatGDI)
#define    PixelFormat32bppRGB        (9 | (32 << 8) | PixelFormatGDI)
#define    PixelFormat32bppARGB       (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical)
#define    PixelFormat32bppPARGB      (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI)
#define    PixelFormat48bppRGB        (12 | (48 << 8) | PixelFormatExtended)
#define    PixelFormat64bppARGB       (13 | (64 << 8) | PixelFormatAlpha  | PixelFormatCanonical | PixelFormatExtended)
#define    PixelFormat64bppPARGB      (14 | (64 << 8) | PixelFormatAlpha  | PixelFormatPAlpha | PixelFormatExtended)
#define    PixelFormatMax             15
Denis
SFSxOI
Messages : 9
Inscription : mer. 07/mars/2007 2:46

Message par SFSxOI »

Denis,

I see now where we are diverging. In the Vista SDK, in the gdiplusenums.h the following is defined:

Code : Tout sélectionner

enum SmoothingMode
{
    SmoothingModeInvalid     = QualityModeInvalid,
    SmoothingModeDefault     = QualityModeDefault,
    SmoothingModeHighSpeed   = QualityModeLow,
    SmoothingModeHighQuality = QualityModeHigh,
    SmoothingModeNone,
    SmoothingModeAntiAlias,
#if (GDIPVER >= 0x0110)
    SmoothingModeAntiAlias8x4 = SmoothingModeAntiAlias,
    SmoothingModeAntiAlias8x8
#endif //(GDIPVER >= 0x0110) 
};
If GDIPVER >= 0x0110 then when this is enumerated will not the values become ???:

Code : Tout sélectionner

#QualityModeInvalid 
#QualityModeDefault 
#QualityModeLow 
#QualityModeHigh 
0 
1 
#SmoothingModeAntiAlias8x4 (which is = 1) 
2

and....in gdipluspixelformats.h the following is defined:

Code : Tout sélectionner

typedef INT PixelFormat;

#define    PixelFormatIndexed      0x00010000 // Indexes into a palette
#define    PixelFormatGDI          0x00020000 // Is a GDI-supported format
#define    PixelFormatAlpha        0x00040000 // Has an alpha component
#define    PixelFormatPAlpha       0x00080000 // Pre-multiplied alpha
#define    PixelFormatExtended     0x00100000 // Extended color 16 bits/channel
#define    PixelFormatCanonical    0x00200000 

#define    PixelFormatUndefined       0
#define    PixelFormatDontCare        0

#define    PixelFormat1bppIndexed     (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define    PixelFormat4bppIndexed     (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define    PixelFormat8bppIndexed     (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define    PixelFormat16bppGrayScale  (4 | (16 << 8) | PixelFormatExtended)
#define    PixelFormat16bppRGB555     (5 | (16 << 8) | PixelFormatGDI)
#define    PixelFormat16bppRGB565     (6 | (16 << 8) | PixelFormatGDI)
#define    PixelFormat16bppARGB1555   (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI)
#define    PixelFormat24bppRGB        (8 | (24 << 8) | PixelFormatGDI)
#define    PixelFormat32bppRGB        (9 | (32 << 8) | PixelFormatGDI)
#define    PixelFormat32bppARGB       (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical)
#define    PixelFormat32bppPARGB      (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI)
#define    PixelFormat48bppRGB        (12 | (48 << 8) | PixelFormatExtended)
#define    PixelFormat64bppARGB       (13 | (64 << 8) | PixelFormatAlpha  | PixelFormatCanonical | PixelFormatExtended)
#define    PixelFormat64bppPARGB      (14 | (64 << 8) | PixelFormatAlpha  | PixelFormatPAlpha | PixelFormatExtended)
#define    PixelFormat32bppCMYK       (15 | (32 << 8))
#define    PixelFormatMax             16   <----------------- yours = 15?
The difference between what your seeing and what i'm seeing is an additional item for the pixel format:

Code : Tout sélectionner

#define    PixelFormat32bppCMYK       (15 | (32 << 8))

This would make PixelFormatMax = 16 for what i'm seeing where as what your seeing is:

PixelFormat64bppPARGB      (14 | (64 << 8) | PixelFormatAlpha  | PixelFormatPAlpha | PixelFormatExtended)

which would make PixelFormatMax = 15 for you.  
these are what i'm seeing, so now I understand where we are seeing different things......

Thank You, keep up the great work :)
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Message par Anonyme2 »

SFSxOI

It's not a good think to have different values for similar constants. May be it'll be interesting to have only a constants file (and for structures too) wich will be usable with version 1.0 and 1.1. We have to put some tests with complilerif and change constants values according GDI+ version.


Désolé pour les messages en anglais mais c'est plus simple pour SFx01 et moi-même.

Il y a des différences pour certaines constantes entre les GDI+ 1.0 et 1.1, je disais qu'il serait bien d'avoir un seul fichier de constantes qui prennent en compte les différences. Cela veut dire aussi que certaines fonctions dans certains cas n'auront probablement pas le même comportement sous VISTA que sous XP, d'où la presque obligation de livrer des exécutables pour la version 1.0 et d'autre pour la version 1.1 (mais bon, on en est pas encore là :mrgreen: :mrgreen: )
SFSxOI
Messages : 9
Inscription : mer. 07/mars/2007 2:46

Message par SFSxOI »

Heureux vous avez expliqué que parce qu'en français je n'aurais jamais pu faire ainsi. La traduction de poissons de Babel va seulement jusqu'ici. :)
Répondre