Texture Packer pvr.ccz files - ios

Can Texture Packer's pvr.ccz files be used in a non cocos2d app? I'd like to use them with core animation. Is this possible?

Out of the box? No.
You can write your own .pvr.ccz texture loader respectively adapt the .pvr.ccz texture loading code from cocos2d. The key part really is just the compression format (ccz) which uses the zlib compression provided by the iOS/Mac SDK. After inflating the compressed file, you end up with a regular PVR texture that you can use in Core Animation.

Related

Is there a way to compress a pdf made with pdfkit?

I’m using pdfkit to create multi-page documents with embedded images, and the files get really large quickly. I can compress them nicely afterwards using Preview on the Mac, and they still look great, so I’m wondering if there is perhaps a setting I’m missing in pdfkit that controls resolution or size, or if there is way to compress them after creating them.
No, there isn't a way of specifying the image compression using PDFKit. It's just putting the image data in a PDF wrapper.
I'd suggest that you probably don't want to reduce the size of the image; but just the compression level. However, if you do, you can use CGPDFDocument and scale the image to fit a particular-sized graphic context.
On macOS, it is possible to create a Quartz Filter programmatically, which can include options for compression, which you can then apply in the options when you write your PDF; but this isn't available in iOS.
(If you're using macOS's 'Reduce File Size' Quartz Filter when exporting from Preview, it's well-known to be not very good; many people have made better ones.)
However, you can set the JPEG compression level in a UIImage object, so you may be able to increase the compression in the image data before you convert it to PDF.
https://developer.apple.com/documentation/uikit/uiimage/1624115-jpegdata/

MIPS and MARS bitmap, loading images?

Is it possible to load images directly to be displayed on MARS bitmap displayer? It seems as if more complex file specifications like .jpeg and .png would be a no go but what about .BMP files? Is it as simple as loading the file into a buffer and displaying it how I would normally using base address for display?
After looking up the BMP spec I realize the spec is still pretty complicated so I guess the question is more along the lines of if I just grab the pixel array from the .BPM file how will it be affected without the other components?

Error while loading pvr.ccz textures in iOS

I'm using TexturePacker to create my sprite sheets for my iOS game. Everything is working fine with generated PNG textures (RGBA 4444), the textures are correctly loaded inside my code and correctly displayed on the iPad screen but as soon I remplace those textures by the PVRC format (pvr.ccz) with PVRTCI 4bpp RGBA pixel format, I get the following message for each of my textures from the console:
"SKTexture: Error loading image resource: "/var/containers/Bundle/Application/657D8692-594C-4180-AA8B-6CE35962C8D5/FurryLight Puzzles.app/Puzzle0.atlasc/Puzzle0.2.pvr.ccz"
The textures generated by TexturePacker are all POT and SQUARE format (2048x2048 max), the plist files are inside my directories .atlasc with the pvr.ccz files. In fact, I just replace the precedent .atlasc directories inside my tree shader inside Xcode with the PNG files by the new .atlasc directories with pvr.ccz files. All my code is in Swift 3.0
What am I missing, is there something to tune somewhere ? The pvr.ccz textures are correctly displayed by Xcode when I click on them inside the tree.
Here is the reply I got from the creators of TexturePacker:
"I am currently not sure if pvr works - you can try it. But pvr.ccz surely does not work.
pvr.ccz is a special format for cocos2d(x). It compresses the pvr files with zlib. This is not supported by SpriteKit.
Best
Andreas
"

WebGL: Asynchronous texImage2D?

I am updating some textures of the scene all the time by new images.
Problem is uploading is synchronous and texImage2D takes ~100ms. It takes so long time even if texture is not used during rendering of the next frame or rendering is switched off.
I am wondering, is there any way to upload texture data asynchronously?
Additional conditions:
I had mention there is old texture which could stay active until uploading of new one to GPU will be finished.
Solution is to use texSubImage2D and upload image to GPU by small portions. Once uploading will be finished activate your new texture and delete old one.
is there any way to upload texture data asynchronously?
no, not in WebGL 1.0. There might be in WebGL 2.0 but that's not out yet.
Somethings you might try.
make it smaller
What are you uploading? Video? Can you make it smaller?
Have you tried different formats?
WebGL converts from whatever format the image is stored in to the format you request. So for example if you load a .JPG the browser might make an RGB image. If you then upload it with gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE it has to convert the image to RGBA before uploading (more time).
Do you have UNPACK_FLIP_Y set to true?
If so WebGL has to flip your image before uploading it.
Do you have UNPACK_COLORSPACE_CONVERSION_WEBGL set to BROWSER_DEFAULT_WEBGL?
If not WebGL may have to re-decompress your image
Do you have UNPACK_PREMULTIPLY_ALPHA_WEBGL set to false or true?
Depending on how the browser normally stores images it might have
to convert the image to the format your requesting
Images have to be decompressed
are you sure your time is in "uploading" vs "decompressing"? If you switch to uploading a TypedArray of the same dimensions does it speed up?

OpenGL ES, how do you render PVR textures?

Edit:ok, sorry, I had a simple programming error, is there a way to delete this question?
I have some compressed textures that are PVR files, but I cant seem to draw them in my iPad application using OpenGL ES.
I can draw PNG files just fine, I know the PVR files are being loaded correctly.
Are there some special OpenGL draw functions that I need to be calling to draw the PVR files?
Edit:All I get is a white image.
Any info is appreciated.
Drawing PVRTC textures should be exactly the same as any other texture format - it looks more likely that your loading code is the problem. Are any GL errors being reported during loading?
The major difference to loading uncompressed textures are in the line:
glCompressedTexImage2D(GL_TEXTURE_2D, level, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, width, height, 0, size, data);
or
glCompressedTexImage2D(GL_TEXTURE_2D, level, GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, width, height, 0, size, data);
Make sure that you're not setting a GL filter mode to use MIPmaps if they're not in the texture as well.
Searching for PVRTC in Apple's docs brings up a decent summary of how to use these textures.
After upload, PVR textures are no different from other formats. Did you forgot to skip header during data upload, or used wrong parameters for glCompressedTexImage2D? It is even possible that compression tool was unable to convert images because of wrong size or color format.

Resources