Рубрики

blue

Procedures for converting green into blue

Download source code here: http://www.eyeClaxton.com/download/delphi/ColorSwap.zip Yes, I want to convert something “mostly blue” to something “mostly green”. I would like to take a original bitmap (light blue) and change the colors (Pixel by Pixel) to the red, green, blue and gray equivalence relation. To get an idea of what I mean, I have include the source code and a screen shot. Any help would be greatly appreciated. If more information is needed, please feel free to ask. If you could take a look at the code below, I have three functions that I’m looking for help on. The functions “RGBToRed, RGBToGreen and RGBToRed” I can’t seem to come up with the right formulas.


Using blue-green deployment to reduce downtime

At any time, only one of the environments is live, with the live environment serving all production traffic.

For the example discussed here, Blue is live and Green is idle. As you prepare a new version of your software, deployment and the final stage of testing takes place in the environment that is not live: in this example, Green. After deploy and fully tested the software in Green, you switch the router so that all incoming requests now go to Green instead of Blue. Green is now live, and Blue is idle.

This technique can eliminate downtime due to app deployment. In addition, blue-green deployment reduces risk: if something unexpected happens with your new version on Green, you can immediately roll back to the last version by switching back to Blue.

You can adjust the route mapping pattern to display a static maintenance page during a maintenance window for time-consuming tasks such as migrating a database. In this scenario, the router switches all incoming requests from Blue to Maintenance to Green.

Important If your app uses a relational database, blue-green deployment can lead to discrepancies between your green and glue databases during an update. To maximize data integrity, configure a single database for backward and forward compatibility.

Blue-green deployment with Cloud Foundry example

For this example, consider a simple app: “demo-time.” This app is a webpage that displays the words “Blue time” and the date/time on the server.

Step 1: Push an app

Use the Cloud Foundry Command Line Interface (cf CLI) to push the app. Name the app “Blue” with the subdomain “demo-time.”

$ cf push Blue -n demo-time

As shown in the graphic:

  • Blue is now running on Cloud Foundry.
  • The Cloud Foundry Router sends all traffic for demo-time.example.com traffic to Blue.

alt-text=

Step 2: Update app and push

Now make a change to the app. 1. Replace the word “Blue” on the webpage with “Green,” then rebuild the source file for the app. 1. Run cf push again, but use the name “Green” for the app and provide a different subdomain to create a temporary route:

$ cf push Green -n demo-time-temp

After this push:

  • Two instances of the app are now running on Cloud Foundry: the original Blue and the updated Green.
  • The Cloud Foundry Router continues sending all traffic for demo-time.example.com to Blue. The router now also sends any traffic for demo-time-temp.example.com to Green.

alt-text=

Step 3: Map original route to Green

Now that both apps are up and running, switch the router so all incoming requests go to both the Green app and the Blue app. Use the cf map-route command to map the original URL route ( demo-time.example.com ) to the Green app.

$ cf map-route Green example.com -n demo-time Binding demo-time.example.com to Green. OK

After the cf map-route command :

  • The Cloud Foundry Router continues sending traffic for demo-time-temp.example.com to Green.
  • Within a few seconds, the Cloud Foundry Router begins load balancing traffic for demo-time.example.com between Blue and Green.

alt-text=

Step 4: Unmap route to Blue

After you verify that Green is running as expected, stop routing requests to Blue using the cf unmap-route command:

$ cf unmap-route Blue example.com -n demo-time Unbinding demo-time.example.com from blue. OK

After the cf unmap-route command:

  • The Cloud Foundry Router stops sending traffic to Blue.

Now all traffic for demo-time.example.com is sent to Green.

alt-text=

Step 5: Remove temporary route to Green

You can now use cf unmap-route to remove the route demo-time-temp.example.com from Green. You can delete the route using cf delete-route or reserved it for later use. You can also decommission Blue, or keep it in case you need to roll back your changes.

alt-text=

Implementation

Cloud Foundry community members have written a plug-in to automate blue-green deployment:

  • BlueGreenDeploy: cf-blue-green-deploy is a plug-in, written in Go, for the Cloud Foundry Command Line Interface (cf CLI) that automates a few steps involved in zero-downtime deployments.


Ammonia Colors

The following diagram represents the main “ammonia colors” which differ in the energy source and in the hydrogen production process.

Ammonia colors

Ammonia colors

Green Ammonia

The rapidly decreasing cost of renewable power generation is putting “green” hydrogen (i.e. produced through electrolysis powered by renewable energy) under the spotlight as a promising energy carrier for a number of applications.

Hydrogen can be compressed or liquefied for storage and transport, a process that is far from ideal due to high CAPEX and OPEX requirements, as well as significant safety risks. One of the most suitable method of transporting hydrogen via sea is to chemically convert the hydrogen molecule into an energy carrier such as ammonia, methanol or liquid organic hydrogen carriers. Among these, ammonia is one of the most promising energy carriers.

Similarly to fossil fuels, ammonia is both a chemical energy carrier and a potential fuel, where energy is released by the breaking of chemical bonds. Crucially, ammonia has the advantage of releasing no carbon emissions when used as a fuel, and its green credentials can be further enhanced if sustainable energy is used to power ammonia production.

Green ammonia

There are a number of key features that make ammonia particularly suitable as a green hydrogen carrier:

  • Ease of storage and transportation: The energy storage properties of ammonia are fundamentally similar to those of methane. The volumetric energy density of ammonia is 150% of liquid hydrogen and these hydrogen densities can be achieved close to ambient storage conditions. This contrasts with the high pressures or low temperatures needed to achieve useful volumetric hydrogen density with pure hydrogen.
  • Ammonia also has lower explosive limits in air than pure hydrogen. As a result, the storage of hydrogen is more difficult, energy intensive and expensive than storing ammonia.
  • Established logistics and end-use markets: There is a high level of maturity in the ammonia supply chain thanks to its widespread use as a feedstock for inorganic nitrogen containing fertilizers and a variety of other industrial chemicals. Ammonia can count on an established global storage and trading infrastructure.
  • High hydrogen density compared to other potential hydrogen carriers.
  • Potential uses as a fuel: Crucially, ammonia can be used directly in ammonia-fired turbines and engines.

Thanks to its experience in designing and revamping hundreds of existing ammonia plants, Casale is able to customize the design of a new Green Ammonia plant with capacity ranging between few MTD up to few thousand MTD of ammonia production with an optimized CAPEX and OPEX.

Hybridization for Grey Ammonia Plant

With the so called “green hydrogen integration”, a traditional (grey) Ammonia plant can be revamped in order to consistently cut energy consumption and CO2 footprint. The Casale approach allows to minimize the intervention in the existing production structure according to the required hybridization degree and to the overall design of the plant.

Green Methanol

“Green” methanol (or bio-methanol) may be produced via biological pathways (anaerobic digestion), thermo-chemical pathways (gasification) or electrofuel pathways (power to gas).

Biomass gasification route leads to a plant which is similar to a coal gasification plant, for which Casale has almost 20 references in China.

In this type of plants Casale can provide the CO-shift section, synthesis loop, distillation and storage. Moreover, according to the methane content in the make-up gas, the purge gas can be processed in an ATR unit equipped with a process gas saturator that uses distillation bottom water to minimize liquid effluents.

Programmatically swap colors from a loaded bitmap to Red, Green, Blue or Gray, pixel by pixel

alt text

Download source code here: http://www.eyeClaxton.com/download/delphi/ColorSwap.zip Yes, I want to convert something “mostly blue” to something “mostly green”. I would like to take a original bitmap (light blue) and change the colors (Pixel by Pixel) to the red, green, blue and gray equivalence relation. To get an idea of what I mean, I have include the source code and a screen shot. Any help would be greatly appreciated. If more information is needed, please feel free to ask. If you could take a look at the code below, I have three functions that I’m looking for help on. The functions “RGBToRed, RGBToGreen and RGBToRed” I can’t seem to come up with the right formulas.

unit MainUnit; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TMainFrm = class(TForm) Panel1: TPanel; Label1: TLabel; Panel2: TPanel; Label2: TLabel; Button1: TButton; BeforeImage1: TImage; AfterImage1: TImage; RadioGroup1: TRadioGroup; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private < Private declarations >public < Public declarations >end; var MainFrm: TMainFrm; implementation function RGBToGray(RGBColor: TColor): TColor; var Gray: Byte; begin Gray := Round( (0.90 * GetRValue(RGBColor)) + (0.88 * GetGValue(RGBColor)) + (0.33 * GetBValue(RGBColor))); Result := RGB(Gray, Gray, Gray); end; function RGBToRed(RGBColor: TColor): TColor; var Red: Byte; begin // Not sure of the algorithm for this color Result := RGB(Red, Red, Red); end; function RGBToGreen(RGBColor: TColor): TColor; var Green: Byte; begin // Not sure of the algorithm for this color Result := RGB(Green, Green, Green); end; function RGBToBlue(RGBColor: TColor): TColor; var Blue: Byte; begin // Not sure of the algorithm for this color Result := RGB(Blue, Blue, Blue); end; procedure TMainFrm.FormCreate(Sender: TObject); begin BeforeImage1.Picture.LoadFromFile('ImagesRightCenter.bmp'); end; procedure TMainFrm.Button1Click(Sender: TObject); var Bitmap: TBitmap; I, X: Integer; Color: Integer; begin Bitmap := TBitmap.Create; try Bitmap.LoadFromFile('ImagesRightCenter.bmp'); for X := 0 to Bitmap.Height do begin for I := 0 to Bitmap.Width do begin Color := ColorToRGB(Bitmap.Canvas.Pixels[I, X]); case Color of : ; // Skip any Color Here! else case RadioGroup1.ItemIndex of 0: Bitmap.Canvas.Pixels[I, X] := RGBToBlue(Color); 1: Bitmap.Canvas.Pixels[I, X] := RGBToRed(Color); 2: Bitmap.Canvas.Pixels[I, X] := RGBToGreen(Color); 3: Bitmap.Canvas.Pixels[I, X] := RGBToGray(Color); end; end; end; end; AfterImage1.Picture.Graphic := Bitmap; finally Bitmap.Free; end; end; end. 

Okay, I apologize for not making it clearer. I’m trying to take a bitmap (blue in color) and swap the blue pixels with another color. Like the shots below. alt text alt text

Colin Wynn
the authorColin Wynn

Leave a Reply