Search Results

Search found 13 results on 1 pages for 'rbg'.

Page 1/1 | 1 

  • RBG to CbyCr conversion code

    - by user1446688
    I am wondering why this code does not work. Basically it is supposed to convert between RGB and CbYCr. When I convert from RGB to CbYCr then back to RGB I do not get the original RGB values. What is wrong with this code? #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)(b))?(a):(b)) struct _rgb { int R; int G; int B; }; typedef struct _rgb rgb; struct _cbycr { int Cb; int Y; int Cr; }; typedef struct _cbycr cbycr; void cbycr2rgb(rgb *c, double Y, double Cb, double Cr) { int r = (int)(Y + 1.40200 * (Cr - 0x80)); int g = (int)(Y - 0.34414 * (Cb - 0x80) - 0.71414 * (Cr - 0x80)); int b = (int)(Y + 1.77200 * (Cb - 0x80)); c->R = MAX(0, MIN(255, r)); c->G = MAX(0, MIN(255, g)); c->B = MAX(0, MIN(255, b)); } void rgb2cbycr(cbycr *c, int R, int G, int B) { c->Y = (int)(0.299 * R + 0.587 * G + 0.114 * B); c->Cb = (int)(-0.16874 * R - 0.33126 * G + 0.50000 * B); c->Cr =(int)(0.50000 * R - 0.41869 * G - 0.08131 * B); } int main() { cbycr _cbycr; rgb _rgb; _rgb.R = 50; _rgb.G = 50; _rgb.B = 50; rgb2cbycr(&_cbycr, _rgb.R, _rgb.G, _rgb.B); cbycr2rgb(&_rgb, _cbycr.Y, _cbycr.Cb, _cbycr.Cr); printf("rgb=%d %d %d\n", _rgb.R, _rgb.G, _rgb.B); return 0; } output: rgb=0 185 0

    Read the article

  • TypeError: Error #2007: Parameter child must be non-null.

    - by Bobby Francis Joseph
    I am running the following piece of code: package { import fl.controls.Button; import fl.controls.Label; import fl.controls.RadioButton; import fl.controls.RadioButtonGroup; import flash.display.Sprite; import flash.events.MouseEvent; import flash.text.TextFieldAutoSize; public class RadioButtonExample extends Sprite { private var j:uint; private var padding:uint = 10; private var currHeight:uint = 0; private var verticalSpacing:uint = 30; private var rbg:RadioButtonGroup; private var questionLabel:Label; private var answerLabel:Label; private var question:String = "What day is known internationally as Speak Like A Pirate Day?"; private var answers:Array = [ "August 12", "March 4", "September 19", "June 22" ]; public function RadioButtonExample() { setupQuiz(); } private function setupQuiz():void { setupQuestionLabel(); setupRadioButtons(); setupButton(); setupAnswerLabel(); } private function setupQuestionLabel():void { questionLabel = new Label(); questionLabel.text = question; questionLabel.autoSize = TextFieldAutoSize.LEFT; questionLabel.move(padding, padding + currHeight); currHeight += verticalSpacing; addChild(questionLabel); } private function setupAnswerLabel():void { answerLabel = new Label(); answerLabel.text = ""; answerLabel.autoSize = TextFieldAutoSize.LEFT; answerLabel.move(padding + 120, padding + currHeight); addChild(answerLabel); } private function setupRadioButtons():void { rbg = new RadioButtonGroup("question1"); createRadioButton(answers[0], rbg); createRadioButton(answers[1], rbg); createRadioButton(answers[2], rbg); createRadioButton(answers[3], rbg); } private function setupButton():void { var b:Button = new Button(); b.move(padding, padding + currHeight); b.label = "Check Answer"; b.addEventListener(MouseEvent.CLICK, checkAnswer); addChild(b); } private function createRadioButton(rbLabel:String, rbg:RadioButtonGroup):void { var rb:RadioButton = new RadioButton(); rb.group = rbg; rb.label = rbLabel; rb.move(padding, padding + currHeight); addChild(rb); currHeight += verticalSpacing; } private function checkAnswer(e:MouseEvent):void { if (rbg.selection == null) { return; } var resultStr:String = (rbg.selection.label == answers[2]) ? "Correct" : "Incorrect"; answerLabel.text = resultStr; } } } This is from Adobe Livedocs. http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/ I have added a Radiobutton to stage and then deleted it so that its there in the library. However I am getting the following error TypeError: Error #2007: Parameter child must be non-null. at flash.display::DisplayObjectContainer/addChildAt() at fl.controls::BaseButton/fl.controls:BaseButton::drawBackground() at fl.controls::LabelButton/fl.controls:LabelButton::draw() at fl.controls::Button/fl.controls:Button::draw() at fl.core::UIComponent/::callLaterDispatcher() Can anyone tell me what is going on and how to remove this error.

    Read the article

  • Prevent Custom Entity being deleted from Entity Framework during Update Model Wizard

    - by rbg
    In Entity Framework v1 If you create a Custom Entity to map it to a Stored Procedure during FunctionImport and then Select "Update Model from Database" the Update Model Wizard removes the Custom Entity (as added Manually in the SSDL XML prior to functionImport) from the SSDL. Does anyone know if this limitation has been dealt with Entity Framework v4? I mean is there a way to prevent the Wizard from removing the Custom Entity from the Storage Schema (SSDL) during Model Update from Database????

    Read the article

  • fragment shader directional light positioning with camera

    - by meWantToLearn
    Im trying to set up directional lighting in the fragment shader. So the direction of my light moves with the camera position. #version 150 core uniform sampler2D diffuseTex; uniform vec4 lightColour; uniform vec3 lightDirection; vec3 LNorm = normalize(lightDirection); vec3 normal = normalize(IN.normal); vec3 calColour = lightColour[i].rgb * intensity; gl_FragColor = vec4(diffuse.rbg * calColour, diffuse.a); It lights the entire scene.

    Read the article

  • How can I set the TextColor of a TextAppearanceSpan?

    - by michael
    Hi, I currently able to create a Medium size TextAppearanceSpan, But how can I set the text color to a specified RBG color (say #c71585)? new TextAppearanceSpan(context, android.R.style.TextAppearance_Medium); I see there is a constructor for public TextAppearanceSpan(Context context, int appearance, int colorList) { But what is the int for colorList? Is there any example for this? Thank you.

    Read the article

  • Load a bitmap from file in RGB format (without alpha)

    - by Robert
    Hi, i simply want to load a .BMP file and get the Bitmap object in 24bit RGB format (or 32bit in RGB format). All methods I tried return a Bitmap/Image object with PixelFormat = Format32bppArgb. Even if of course BMPs don't have alpha. new Bitmap(System.Drawing.Image.FromFile(fileName, true)); new Bitmap(fileName); I currently solve the problem by copying the first object to another in memory bitmap at 24bit RBG. Is there a single method to do it? Thanks

    Read the article

  • command binding for ribbon control

    - by kartik
    I'm trying to use the Microsoft ribbon control programatically using C#. Everything is fine but I'm unable to bind the command through the RibbonCommand. Can anyone give me an example of how to do this? My actual code is: Ribbon rbn = new Ribbon(); RibbonTab file = new RibbonTab(); file.Name = "file"; file.Label = "FILE"; RibbonTab edit = new RibbonTab(); edit.Name = "edit"; edit.Label = "Edit"; RibbonGroupPanel rbgp = new RibbonGroupPanel(); RibbonGroup rbg = new RibbonGroup(); RibbonButton rbtn = new RibbonButton(); rbtn.Content = "New"; RibbonCommand rcomnd = new RibbonCommand(); rcomnd.LabelTitle = "NEW"; rcomnd.ToolTipDescription = "THIS IS NEW"; rcomnd.LargeImageSource = imgSource; rcomnd.Execute(rbtn, rbtn); rbtn.IsEnabled = true; //rcomnd.SmallImageSource = imgSource; rcomnd.CanExecute +=new CanExecuteRoutedEventHandler(rcomnd_CanExecute); rcomnd.Executed +=new ExecutedRoutedEventHandler(rcomnd_Executed); CommandBinding cmdb = new CommandBinding(ApplicationCommands.New); cmdb.Command = ApplicationCommands.New; cmdb.Executed +=new ExecutedRoutedEventHandler(cmdb_Executed); CommandBind.Add(cmdb); //rcomnd.Executed += new ExecutedRoutedEventHandler(OnAddNewEntry);*/ rbtn.Click +=new System.Windows.RoutedEventHandler(rbtn_Click); rbtn.Command = rcomnd; But the bindings are not working and the button is not enabled.

    Read the article

  • File Format Conversion to TIFF. Some issues???

    - by Nains
    I'm having a proprietary image format SNG( a proprietary format) which is having a countinous array of Image data along with Image meta information in seperate HDR file. Now I need to convert this SNG format to a Standard TIFF 6.0 Format. So I studied the TIFF format i.e. about its Header, Image File Directories( IFD's) and Stripped Image Data. Now I have few concerns about this conversion. Please assist me. SNG Continous Data vs TIFF Stripped Data: Should I convert SNG Data to TIFF as a continous data in one Strip( data load/edit time problem?) OR make logical StripOffsets of the SNG Image data. SNG Data Header uses only necessary Meta Information, thus while converting the SNG to TIFF, some information can’t be retrieved such as NewSubFileType, Software Tag etc. So this raises a concern that after conversion whether any missing directory information such as NewSubFileType, Software Tag etc is necessary and sufficient condition for TIFF File. Encoding of each pixel component of RGB Sample in SNG data: Here each SNG Image Data Strip per Pixel component is encoded as: Out^[i] := round( LineBuffer^[i * 3] * **0.072169** + LineBuffer^[i * 3 + 1] * **0.715160** + LineBuffer^[i * 3+ 2]* **0.212671**); Only way I deduce from it is that each Pixel is represented with 3 RGB component and some coefficient is multiplied with each component to make the SNG Viewer work RGB color information of SNG Image Data. (Developer who earlier work on this left, now i am following the trace :)) Thus while converting this to TIFF, the decoding the same needs to be done. This raises a concern that the how RBG information in TIFF is produced, or better do we need this information?. Please assist...

    Read the article

1