PDA

View Full Version : NSImage of text quality



topherreynoso
09-09-2009, 12:17 PM
Hello all,

Still fairly new to OpenGL. I am trying to load a texture from an NSImage and it is loading it fine except that the quality is not all that great. The NSImage is of a page from a PDF document and the quality of the text is not good enough to read. I have tried doing it with mipmapping and without mipmapping, without mipmapping seems to be closer to where it should be but the quality still isn't good enough to make the texture readable to a user. Any ideas on how I could address this problem?

topherreynoso
09-10-2009, 09:39 PM
So here's some code from what I'm doing, please let me know if you see any glaring errors or if there is something I'm missing to maintain the quality of the text in the NSImage.



NSPDFImageRep *pdfImage...
NSImage *pageImage = [[NSImage alloc] init];
[pageImage addRepresentation:pdfImage];

NSBitmapImageRep *bitmapimagerep = [[NSBitmapImageRep alloc] initWithData:[pageImage TIFFRepresentation];

NSRect rect = NSMakeRect(0, 0, [bitmapImageRep pixelsWide], [bitmapImageRep pixelsHigh]);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, (([bitmapImageRep hasAlpha]) (GL_RGBA):(GL_RGB)), rect.size.width,
rect.size.height, 0, (([bitmapImageRep hasAlpha])?(GL_RGBA):(GL_RGB)), GL_UNSIGNED_BYTE, [bitmapImageRep bitmapData]);


Any help or suggestions for filters or ways to increase the quality and clarity of the text would be greatly appreciated.

topherreynoso
09-14-2009, 07:48 PM
I know that this was a really dumb problem that wasn't even worth responding to but... like I said I'm new.

So here's how I solved the problem, in case someone else comes across a similar problem.

Instead of setting the NSImage up with [[NSImage alloc] init], I decided to specify a size for the NSImage and that changed everything. I don't know what size NSImage loads on its own by default, but it was no where near large enough for my PDF to be used as a texture in openGL. Instead, I did the following:

NSImage *pageImage = [[NSImage alloc] initWithSize:NSMakeSize(1024, 1024)];

Voila, problem solved, one higher quality PDF now loaded in as a texture in OpenGL.