[COCOA][NSBitmapImageRep] Image à l'invers
Hello,
Comme le titre l'indique, mon image se charge mais inversée horizontalement.
Par exemple, l'image suivante :
http://www.imaginence.fr/images/logo_developpez.com.gif
Et une fois chargée, j'ai :
http://coderoutier.com/images_articles/developpez.png
En gros, dire à NSBitmapImageRep de charger les images dans le bon sens.
Le code suivant charge l'image :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| LDEuint LDEimage::load( string path )
{
string mypath = path.substr( 0, path.rfind("/") );
string name = path.substr( path.rfind("/")+1, path.rfind(".")-(path.rfind("/")+1) );
string type = path.substr( path.rfind(".")+1, path.length()-path.rfind(".")+1 );
NSString* NSS_textureName = [NSString stringWithCString:name.c_str() encoding:NSUTF8StringEncoding];
NSString* NSS_textureType = [NSString stringWithCString:type.c_str() encoding:NSUTF8StringEncoding];
NSString* NSS_texturePath = [NSString stringWithCString:mypath.c_str() encoding:NSUTF8StringEncoding];
NSString* path_objc = [NSBundle pathForResource:NSS_textureName ofType:NSS_textureType inDirectory:NSS_texturePath];
NSData *raw = [NSData dataWithContentsOfFile:path_objc];
NSBitmapImageRep *rep = [NSBitmapImageRep imageRepWithData:raw];
if ( rep != nil )
{
w = [rep size].width;
h = [rep size].height;
bpp = [rep samplesPerPixel];
data = new LDEubyte[w*h*bpp];
data = [rep bitmapData];
loaded = 1;
}
else
cout << " ! Error loading image \""<<mypath<<"/"<<name<<"."<<type<<"\"\n";
return loaded;
} |
Merci par avance :mrgreen: