Reptillian Posted July 23, 2022 Share Posted July 23, 2022 (edited) A simple plugin to convert images from RGB-8 to HSV-8 (0-255 Range). There's no parameter. Just click it after installation. After installation, you will find this under Effect->Color. Download Link - RGB2HSV8.zip Preview: Code License: CC0 (Free to use, no credits or permission required) Codelab Source (Too simple to figure out, but here it goes): Spoiler // Name: RGB-8 To HSV-8 // Submenu: Color // Author: Reptorian // Title: RGB-8 To HSV-8 // Version: 1 // Desc: Convert RGB-8 To HSV-8 // Keywords: Color // URL: https://forums.getpaint.net/profile/85868-reptillian/ // Help: #region UICode #endregion float mod(float x, float m) { return (x%m + m)%m; } void Render(Surface dst, Surface src, Rectangle rect) { // Delete any of these lines you don't need int R,G,B,M,C; float H,fR,fG,fB,fM,fC,S; ColorBgra currentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { if (IsCancelRequested) return; for (int x = rect.Left; x < rect.Right; x++) { currentPixel = src[x,y]; R = currentPixel.R; G = currentPixel.G; B = currentPixel.B; M = Math.Max(Math.Max(R,G),B); C = M - Math.Min(Math.Min(R,G),B); fR=(float)(R); fG=(float)(G); fB=(float)(B); fM=(float)(M); fC=(float)(C); H = 42.618f*( C==0?0 :M==R?mod((fG - fB)/fC,6) :M==G?(fB - fR)/fC + 2f :(fR - fG)/fC + 4f ); S=M<=0?0:fC/fM; dst[x,y] = ColorBgra.FromBgraClamped(M,(float)(Math.Round(S*255)),(float)(Math.Round(H)),currentPixel.A); } } } Edited July 31, 2022 by Reptillian 1 2 Quote G'MIC Filter Developer Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.