IPB

Bienvenue invité ( Connexion | Inscription )

> Programmation

Il est interdit de poster directement à la racine de ce forum.
Veuillez créer votre topic dans le sous-forum approprié.

 
Reply to this topicStart new topic
> Enregistrer une image autrement qu'en "TIFF"
Options
Guest_Mic3D_*
posté 19 Jul 2004, 14:14
Message #1





Guests






Salut,

La question est résumée dans le titre. Que ce soit avec une NSImage, NSImageRep ou NSBitmapImageRep... je n'arrive jamais à créer une "image.jpg" ou autre "png", "gif", etc...

Merci et bonne fin de journée wink.gif

-- Edition --

CODE
NSBitmapImageRep *im=[NSBitmapImageRep imageRepWithData:[img TIFFRepresentation]];
NSData *d=[[NSData alloc] initWithData:[im representationUsingType:NSJPEGFileType properties:nil]];


Ce message a été modifié par Mic3D - 19 Jul 2004, 14:49.
Go to the top of the page
 
+Quote Post
cbrandt
posté 19 Jul 2004, 14:57
Message #2


Macbidouilleur de bronze !
**

Groupe : Membres
Messages : 291
Inscrit : 29 May 2004
Lieu : 48°50'27" N, 2°13'43" E
Membre no 19 336



Bonjour,

CODE
   NSBitmapImageRep       *rep;
   NSData    *inData, *outData;
...
   inData = [NSData dataWithContentsOfFile: <chemin vers fichier>];
   rep = [NSBitmapImageRep imageRepWithData: inData];
   outData = [rep representationUsingType: NSJPEGFileType properties: nil];
...


Ce message a été modifié par cbrandt - 19 Jul 2004, 14:58.


--------------------
Membre no. 14 du club des AIPBP (Anciens Inscrits Pas Beaucoup de Posts) Voir la liste
Go to the top of the page
 
+Quote Post
Arty
posté 19 Jul 2004, 17:52
Message #3


Macbidouilleur d'Or !
*****

Groupe : Membres
Messages : 1 599
Inscrit : 20 Sep 2003
Membre no 9 702



La question m'intéresse aussi. J'ai essayé le bout de code suivant:

CODE
#include <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
   NSAutoreleasePool   *pool = [[NSAutoreleasePool alloc] init];
   NSBitmapImageRep    *rep;
   NSData              *inData, *outData;
   
   inData = [NSData dataWithContentsOfFile:@"/Users/arthur/Pictures/IMG_0944.JPG"];
   rep = [NSBitmapImageRep imageRepWithData:inData];
   outData = [rep representationUsingType:NSBMPFileType properties:[NSDictionary dictionary]];
       
   NSLog(@"Sortie: %@", outData);
   
   [pool release];
   
   return 0;
}

Quand je lance le programme, j'obtiens:

CODE
Sortie: (NULL)


Je comprend pas pourquoi....

Ce message a été modifié par Arty - 19 Jul 2004, 17:52.


--------------------
MacBook Pro 15" Core [email protected]
Mac OS 10.9.3
iPhone 5 - 32 Go Black
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



Nous sommes le : 26th April 2024 - 16:30