logo
down
shadow

Add a background colour to a MediaComposition


Add a background colour to a MediaComposition

By : Sakshi
Date : November 22 2020, 02:59 PM
this will help The only thing I understand about this is you are trying to save an image with a background. My suggestion to solve this is to save the transparent image you have to something like
code :
<StackPanel x:Name="AreaWhichWillBeSavedToImage" Background=*Some Color*>
  <Image x:Name="theAlphaImage">
</StackPanel>
var bitmap = await SaveToFileAsync(AreaWhichWillBeSavedToImage, await StorageFile.GetFileFromPathAsync(Windows.ApplicationModel.Package.Current.InstalledLocation.Path + @"someimage.jpg"));

  async Task<RenderTargetBitmap> SaveToFileAsync(FrameworkElement uielement, StorageFile file)
    {
        if (file != null)
        {
            CachedFileManager.DeferUpdates(file);

            Guid encoderId = GetBitmapEncoder(file.FileType);

            try
            {
                using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                {
                    return await CaptureToStreamAsync(uielement, stream, encoderId);
                }
            }
            catch (Exception ex)
            {
                //DisplayMessage(ex.Message);
            }

            var status = await CachedFileManager.CompleteUpdatesAsync(file);
        }

        return null;
    }

    async Task<RenderTargetBitmap> CaptureToStreamAsync(FrameworkElement uielement, IRandomAccessStream stream, Guid encoderId)
    {
        try
        {
            var renderTargetBitmap = new RenderTargetBitmap();
            await renderTargetBitmap.RenderAsync(uielement);

            var pixels = await renderTargetBitmap.GetPixelsAsync();

            var logicalDpi = DisplayInformation.GetForCurrentView().LogicalDpi;
            var encoder = await BitmapEncoder.CreateAsync(encoderId, stream);
            encoder.SetPixelData(
                BitmapPixelFormat.Bgra8,
                BitmapAlphaMode.Ignore,
                (uint)renderTargetBitmap.PixelWidth,
                (uint)renderTargetBitmap.PixelHeight,
                logicalDpi,
                logicalDpi,
                pixels.ToArray());

            await encoder.FlushAsync();

            return renderTargetBitmap;
        }
        catch (Exception ex)
        {
            //DisplayMessage(ex.Message);
        }

        return null;
    }

    Guid GetBitmapEncoder(string fileType)
    {
        Guid encoderId = BitmapEncoder.JpegEncoderId;
        switch (fileType)
        {
            case ".bmp":
                encoderId = BitmapEncoder.BmpEncoderId;
                break;
            case ".gif":
                encoderId = BitmapEncoder.GifEncoderId;
                break;
            case ".png":
                encoderId = BitmapEncoder.PngEncoderId;
                break;
            case ".tif":
                encoderId = BitmapEncoder.TiffEncoderId;
                break;
        }

        return encoderId;
    }


Share : facebook icon twitter icon
xcode iPhone app background colour is different to iPad background colour

xcode iPhone app background colour is different to iPad background colour


By : SergeyKa
Date : March 29 2020, 07:55 AM
around this issue In my application I use one storyboard for both iPhone and iPad, however when I look at the application on a device for some reason the background colour on the ipad isn't coming out. See images. , Resolved by the following code.
code :
#define UIColorFromRGB(rgbValue) \
[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0x00FF00) >>  8))/255.0 \
blue:((float)((rgbValue & 0x0000FF) >>  0))/255.0 \
alpha:1.0]

cell.backgroundColor = UIColorFromRGB(HEXCODE);
selection of new anchor changes background colour and removes background colour of previously clicked anchor

selection of new anchor changes background colour and removes background colour of previously clicked anchor


By : Ahmad Abdelsatar
Date : March 29 2020, 07:55 AM
Any of those help It's not clear to me exactly what you are trying to do but the linked Jquery can be amended to meet your structure.
code :
$('#header a').click(function() {
    $('#header a').not(this).removeClass('selected');
    $(this).addClass('selected');
});
/*relevant code*/
.head:active {
    background-color: blue;
}

a .label {
	width: 100% !important;
	height: 40px !important;
	display: block !important;
}

#header {
	width: 100%;
	display: flex;
	flex: 0 1 auto;
	flex-wrap: no-wrap;
	flex-direction: row;
	height: 40px;
	margin: 5px auto;
}

.head {
	height: 100%; line-height: 40px;
	flex-grow: 1;
	margin: 0px;
	text-align: center; text-decoration: none; color: #000000; font-weight: bold;
	border-right: thin black solid;
	box-sizing: border-box;
}

.head li {
	height: 100%; line-height: 40px;
	flex-grow: 1;
	margin: 0px;
	text-align: center; text-decoration: none; color: #000000; font-weight: bold;
	border-right: thin black solid;
	box-sizing: border-box;
}

.head:first-child {
	border-bottom: none;
}


.head:hover {
	color: #00ABFF;
}

.head:first-child {
	flex-grow: 3;
	background-color: black;
	color: white;
	text-transform: uppercase;
}

.selected { background: red; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="header">
  <a class="head">Title</a>
  <a class="test head">
    <label for="tab1" id="label1" class="label">Tab 1</label>
  </a>
  <a class="test head">
    <label for="tab2" id="label2" class="label">Tab 2</label>
  </a>
  <a class="test head">
    <label for="tab3" id="label3" class="label">Tab 3</label>
  </a>
  <a class="test head">
    <label for="tab4" id="label4" class="label">Tab 4</label>
  </a>
</div>
Change the background colour and the query-background colour in SearchView fails

Change the background colour and the query-background colour in SearchView fails


By : Rizki
Date : March 29 2020, 07:55 AM
this will help Seems like android:queryBackground only accept a resource ID. Just use a color resource instead of hardcoded hex. Keep this in mind.
code :
 <color name="white">#FFFFFF</color>

 <SearchView
    android:id="@+id/search_view_id"
    android:layout_width="250dp"
    android:layout_height="wrap_content"
    android:queryHint="Search"
    android:iconifiedByDefault="false"
    android:layout_gravity="center"
    android:background="@color/colorPrimary"
    android:queryBackground="@color/white"/>
For Uiimageview how to set the CGgradient background colour as background colour in ios swift4?

For Uiimageview how to set the CGgradient background colour as background colour in ios swift4?


By : Angela
Date : March 29 2020, 07:55 AM
I wish this help you , You can make image from gradient and set it in imageView
code :
let gradient = CAGradientLayer()
let screenWidth = UIScreen.main.bounds.size.width
let defaultNavigationBarFrame = CGRect(x: 0, y: 0, width: screenWidth, height: 64)
gradient.frame = defaultNavigationBarFrame

//colors
let gradientDark = UIColor(red: 148/255.0, green:210/255.0, blue: 245/255.0, alpha: 1.0)
let gradientLight = UIColor(red: 222/255.0, green:247/255.0, blue: 230/255.0, alpha: 1.0)
let gradientLight1 = UIColor(red: 245/255.0, green:247/255.0, blue: 206/255.0, alpha: 1.0)

gradient.colors = [gradientDark.cgColor,gradientLight.cgColor,gradientLight1.cgColor]
// Create image.
let imageBG: UIImage = self.gradientImage(fromLayer: gradient)
self.navigationController?.navigationBar.setBackgroundImage(imageBG,
                                                                for: .default)
func gradientImage(fromLayer layer: CALayer) -> UIImage {
    UIGraphicsBeginImageContext(layer.frame.size)

    layer.render(in: UIGraphicsGetCurrentContext()!)

    let outputImage = UIGraphicsGetImageFromCurrentImageContext()

    UIGraphicsEndImageContext()

    return outputImage!
}
Window's Background Colour Different than ViewController's Background Colour

Window's Background Colour Different than ViewController's Background Colour


By : jstampe
Date : March 29 2020, 07:55 AM
wish help you to fix your issue You should change your leftViewBackgroundColor from storyboard. Add following key path and select type as UIColor and set your custom color. See following image:
Related Posts Related Posts :
  • Why does ReSharper recommend the removal of its own fix?
  • WPF UserControl with nullable dependency property dependent on checkbox value
  • Generating a random number and putting it in a TextBlock
  • Convert datetime string with this format: (yyyy-MM-dd'T'hh:mm:ss-zzz)
  • Check for True or Null value in Linq to Entity
  • Overload resolution, extension methods and genericity in C#
  • Mono can't load Facebook library (from NuGet)
  • Enumerating sql server instances
  • How to avoid duplicate primary key in Entity Framework manual Insert?
  • Shift + F10 in TextBox KeyDown event
  • Failed to assign to property 'Windows.UI.Xaml.Controls.ContentControl.Content'
  • Factory Pattern without a Switch or If/Then
  • c# How to make smooth arc region using graphics path
  • How to Optimize Reactive implementation of recursive function
  • Encrypted connection string can not be decrypted
  • How to know if a user can read and list files of a directory
  • How to get a list of recently edited files?
  • System.ArgumentOutOfRangeException linq c#
  • Uri canonicalization compacting FTP scheme
  • Detecting foreign key conflicts
  • Autofac multiple database support
  • 'System.NullReferenceException'
  • Set a different language for ASP.NET MVC errors
  • checkbox checked or click event not firing in datatemplate
  • Get Current Executable Directory On Map Drive
  • Would executing the SqlCommand be completely moot/redundant, and slow things down?
  • Table To Dictionary <String,Object> using Lambda Expression
  • Azure Service Bus Queue sending a message in NodeJs to .NET client
  • Create Unique Hashcode for the permutation of two Order Ids
  • Cannot submit selected option to contoller
  • How to upsert a document in MongoDB .Net?
  • C# Passing a Class Property Name as String Parameter
  • Remove all occurences of several characters from a string
  • How to configure Teamcity to ignore some tests
  • Why am I getting a cannot implicitly convert int to bool error?
  • C# ScrollBar in TableLayoutPanel with FlowLayouts
  • datagridview custom fill resize
  • MVC - ICollection within List won't return to Controller on POST
  • SQL query into LINQ in asp.net mvc
  • Pick().If() vs Where() in Windsor Castle
  • Entity Framework 6 deep copy/clone of an entity with dynamic depth
  • Relay response slow using Arduino via C# and PC USB
  • Visual Studio 2015 Code Analysis vs FxCopCmd.exe difference
  • Simulating the Enter key in WPF
  • Do not convert JToken date time string as DateTime
  • Using a for loop when calling a method
  • Error configuring relationship using Fluent
  • Unable to find expected objects in VS 2015 memory usage profiler
  • Build an executable file without Microsoft Visual Studio from project file
  • C# Biginteger for huge number of bits
  • Is returning a Task violating the CQS-principle?
  • Foreach loop, tasks and DataGridViewRows within a DataGridView in C#
  • Where I can find Microsoft.DirectX assembly to reference
  • Retrieve process- or thread-id of global keypress using SetWindowsHookEx
  • SSL error on implementing HSTS
  • Group by with different select in linq
  • What are the groups of four dashes in the .NET reference source code?
  • string literal and memory representation
  • EntityFramework is painfully slow at executing an update query
  • Detect if headphones are plugged in or not via C#
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co