- Home /
CMYK Image to Sprite render
Hello,
I would like to ask if what approach to do in order to convert CMYK image to sprite. I tried once just a simple code see snipet below.
Currently Im using Unity 5.6.6f2
public Texture2D convert_image_ToTexture(string path)
{
byte[] filedata = File.ReadAllBytes(path);
Texture2D txt = new Texture2D(90, 90);
txt.LoadImage(filedata);
return txt;
}
Texture2D textture = new ImahetoSprite_Convrtr().convert_image_ToTexture(path);
ImgLogo1.sprite = Sprite.Create(textture, new Rect(0, 0, textture.width, textture.height), new Vector2(.5f, .5f));
but I got an question mark render.
can someone help me with my problem? Thanks in advance.
Answer by Bunny83 · Sep 12, 2018 at 09:12 AM
LoadImage can only load jpg or png images at runtime. No other image format is supported. If you want to load a different format you need to either implement the loader yourself or find one that you can use. You haven't mentioned the actual image file format so we can't suggest anything.
Note that C$$anonymous$$Y$$anonymous$$ is a color model that is used in printing. Though it's unsuited for anything that should be displayed on a screen. Note that there is no generally valid conversion between C$$anonymous$$Y$$anonymous$$ and RGB since both are device dependent. So even software (like Photoshop) that is designed to do such conversion just uses certain color profiles to do the conversion. Unity is a game engine and exclusively outputs to a screen and therefore to RGB. So you really should convert your images to RGB before you use it in Unity.
Answer by imZEH · Sep 12, 2018 at 09:33 AM
Thanks for the response Bunny83.
Sorry, I forgot to mention the format but I tried to convert to sprite is jpg format which is CMYK mode doesn't convert to sprite. I'm pretty sure gif doesn't really support unity but for jpg and png which is RGB mode works well.
Note that storing cmyk in a jpg is very unusual and probably most consumer software that supports reading jpg doesn't support any other images than RGB (which are usually stored as YCbCr). Also note that almost always when we talk about jpg we talk about the JFIF standard.
For everyone that is interested how JFIF / JPEG works i recommend the jpeg series of computerphile
Your answer
![](https://koobas.hobune.stream/wayback/20220612174444im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Texturing custom 2d sprite 0 Answers
Multiple Cars not working 1 Answer
Change texture of plane pixel by pixel (Unity 5) 0 Answers
How to make a WebCamTexture 'run'? 0 Answers
Distribute terrain in zones 3 Answers