Last Updated: 25 Oct 2017 11:47 by ADMIN
Pavel R. Pavlov
Created on: 31 Jan 2014 11:01
Category: Barcode
Type: Bug Report
Barcode: Background and Foreground properties of RadBarcodeQR/RadBarcodePDF417 are ignored
When the Background / Foreground property of the RadBarcodeQR control is set, at runtime time that property is ignored.

On loaded, change the pixel value  of the ImageSource of the code in the following manner
(in case the Foreground is set to a valid SolidColorBrush value):

public void RadBarcodeQR_Loaded(object sender, RoutedEventArgs e)
	Image image = this.ChildrenOfType<Image>().First();
	ImageSource src = image.Source;
	Color c = ((sender as RadBarcodeQR).Foreground as SolidColorBrush).Color;
	image.Source = ChangePixelValue(src, c);

public static WriteableBitmap ChangePixelValue(ImageSource src, Color c)
	BitmapSource originalSource = src as BitmapSource;
	WriteableBitmap modifiedSource = new WriteableBitmap(originalSource);

	int h = modifiedSource.PixelHeight;
	int w = modifiedSource.PixelWidth;
	int[] pixelData = new int[w * h];
	int widthInBytes = 4 * w;

	modifiedSource.CopyPixels(pixelData, widthInBytes, 0);

	int colorInt = BitConverter.ToInt32(new byte[] { c.B, c.G, c.R, 0x00 }, 0);
	for (int i = 0; i < pixelData.Length; i++)
		pixelData[i] ^= colorInt;

	modifiedSource.WritePixels(new Int32Rect(0, 0, w, h), pixelData, widthInBytes, 0);
	return modifiedSource;
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)