In my app, I convert and process images.
from colour to greyscale, then doing operations such as histogram-equalisation, filtering, etc.
that part works fine.
my UIImage display correctly, I also save them to jpeg files and it works.
The only problem is that, although my images are now greyscales, they are still saved as RGB jpegs. that is the red, green and blue value for each pixel are the same but it still waste space to keep the duplicated value, making the file size higher than it could be.
So when i open the image file in photoshop, it is black & white but when I check "Photoshop > Image > Mode", it still says "RGB" instead of "Greyscale".
Anyone know how to tell iOS that the UIImageJPEGRepresentation call should create data with one channel per pixel instead of 4?
Thanks in advance.
You should do an explicit conversion of your image using CGColorSpaceCreateDeviceGray() as color space which is 8 bits per component, 1 channel.
Related
I've spent hours in trying to figure this one out.
Goal
Display P3 PDF Asset in UIImageView (the PDF is 100% in P3 Color Space).
Issue
I'm creating a P3 PDF asset and adding into the Xcode. Within the Asset Catalog, the asset appears in the correct P3 color. When using the asset inside UIImageView and running on iPhone X ( physical device, supports P3 Color Space ), the asset showing is SRGB instead of P3.
Does anyone has information on how to resolve this issue?
Any help will be highly appreciated.
Roi
Use PNG directly
You mention you suspect there is a PNG inside the PDF. I would recommend to use PNG directly without a wrapping PDF.
PDFs are rendered by Apple to PNG when they are deployed on a device. This rendering may apply a specific color profile (PDF and color management is a broad topic).
Also the rendering itself might not produce the results you are expecting, see e.g. https://bjango.com/articles/idontusepdfs/
16 bits per pixel (per channel)
Apple's Human Interface Guidelines state one has to use 16 bits per pixel and export images in .png format.
When appropriate, use the Display P3 color profile at 16 bits per pixel (per channel) and export images in .png format.
see here: https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/color/#color-management
Finally, I'd like to mention just two more settings that you are probably already using:
Compression
In the attributes inspector for image assets you should choose 'Lossless'.
Gamut
Swicht Gamut to 'sRGB and Display P3' and then make sure your image is in a 'Display P3' slot in the .xcasset file.
Test with PNG export of Sketch
Taking a look at the chromaticity diagram, one can see that the P3 color space has a larger gamut for greenish colors.
Since I am not sure whether I can recognize the difference between the two color spaces, I have made the following experiment:
inserted a artboard in Sketch
created a green rectangle with the color #00FF00
assigned under <File/Change Color Profile> the Display P3 color profile
selected the rectangle and clicked Exported selected
have chosen .png without interlacing
Then I did the very same but with sRGB ICE61966-2.1 profile.
I checked both .pngs in the ColorSync utility (can be found under /Applications/Utilities). Pressing the image info toolbar button one can see, that the correct ColorSync profiles are assigned.
In Affinity Photo I checked under <Document/Colour Format> the number of bits per channel. It was for both .pngs 8bit per channel, so I created two additional .pngs with 16bits per channel and named it accordingly.
Then I added the 4 .pngs to a .xcassets folder with the following settings:
Compression: 'Lossless'
Scale: 'Single Scale'
Gamut: 'sRGB and Display P3'
assigned the .pngs accordingly to the correct slot (either sRGP or Display P3).
Then I deployed to iPhone X.
Result: Actually I can see a difference between the green rectangles. The 'Display P3' do have indeed a more saturated green.
I exported the same thing to an old iPhone, where I can't spot any differences between the sRGB and Display P3 images.
I found it interesting that the 8-bit variant directly from Sketch also works, so 16 bits per channel doesn't seem to be a hard requirement.
Did you select the gamut setting for your asset?
How did you verifiy that the image is in SRGB on the iPhone X?
Maybe the WWDC16 talk is somethink to check again:
talk slides
I have an original iPad.
I have noticed that certain sites/documents display in the opposite colors they should--a white background is black, a red image is green, a blue image is yellow.Now I have created a masthead in Photoshop using white, blue and green. It is a jpeg if that makes any difference.
On all of my devices it displays properly except on the iPad where it displays as black, gold, and purple--and totally clashes with everything else.
This is the site, if that helps--sorry I can't seem to insert it as a hyperlink. It is only a temp site, so this is not earth shattering, but I would like to know how to prevent this for future sites.
The image http://reformsbcounty.com/wp-content/uploads/2012/10/ReformHeader-copy2.jpg is using a CMYK colorspace. You should try to use a RGB colorspace for the web (24bit image). There is a fuss about JPEG CMYK color bytes which are stored inverted by PhotoShop (adding a special marker that not all JPEG consumers interpret) . 0% color is stored as 0xFF (and 100% as 0x00) while the standard is 0->0 100%->0xFF. So try converting your images as RGB images should give you a correct rendering on all devices.
I'm using the color information in the texture still when the alpha is set to 0. The PNG file is correctly saved with the color preserved. If I use the content pipeline and set it to non-premultiplied, everything works fine. Texture2D.FromStream is documented as non-premultiplied but it's wiping out the color. When debugging in PIX and looking at the texture, all pixels with 0 alpha are set to black.
Is there a way I can bypass the content pipeline and still keep my color for transparent pixels?
I'm not able to help too much just now as I don't have code in front of me but I done this a few days ago myself and it had all the correct transparency that was expected. Perhaps it's your image that has an issue? I used a PNG saved using Paint.Net.
As seen in this image http://imgur.com/Qrqqo the boat, tree trunk and ladder all have transparency which allow them to be on a second layer and the tileset itself is loaded using from stream (User generated content ftw).
So if no-one has answered this before I get to my computer with code then I'll take a look at what I have and post a sample if needed.
I want to convert some animated PNG (APNG) images to animated GIF. I can successfully convert with a utility I found on the web called apng2gif. Expertly named if I may say. The problem is it does not convert the images with sufficient color depth so the output is a little bit to pixelated and not so smooth relative to the original.
Does anyone know of any other image converters that might convert APNG to GIF with more that 16 bit color depth?
The problem is not with the converter, but with GIF format itself:
http://en.wikipedia.org/wiki/Graphics_Interchange_Format
The format supports up to 8 bits per pixel thus allowing a single image to reference a palette of up to 256 distinct colors.
If you need the GIF to blend better with the background, click on Settings button in apng2gif and then choose the background color you want.
I am able to use PNGs that have drop shadows but the effect when displayed on the BlackBerry looks like it collapses the transparent channel down from its original smooth gradient to only several transparent values giving it a choppy look.
The same issue is encountered by drawing on the UI using BlackBerry fields or the graphics.drawBitmap method. Anyone want to share hints for getting great looking transparent effects on the BlackBerry?
Dither your images or pre-composite them. When loading an image on a BlackBerry, you get at most 4 bits of alpha data, which allows 4 bits each for RGB. So, if you want to dither your transparent images, go for RGB4444. If you don't dither them, that's what causes 8-bit alpha to just be mapped to the nearest 4-bit value.
If you include no alpha data (i.e., precomposite), you can get RGB565, which will have a better image quality overall, but you will have to deal with static positioning for your dropshadows.