ArticleslgStudy

computer science

9-slice scaling

9-slice scaling is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand 9-slice scaling rather than just read about it. In short: 9-slice scaling (also known as Scale 9 grid, 9-slicing or 9-patch) is a 2D image resizing technique to proportionally scale an image by splitting it into a grid of nine parts. The key idea is to prevent image scaling distortion by protecting the pixels defined in 4 parts (corners) of the image and scaling or repeating the pixels in the other 5 parts.

9-slice scaling — main illustration
9-slice scaling — illustration

Key takeaways

  • 9-slice scaling belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect 9-slice scaling to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of 9-slice scaling from memory before moving on to harder problems.

Reference excerpt

9-slice scaling (also known as Scale 9 grid, 9-slicing or 9-patch) is a 2D image resizing technique to proportionally scale an image by splitting it into a grid of nine parts. The key idea is to prevent image scaling distortion by protecting the pixels defined in 4 parts (corners) of the image and scaling or repeating the pixels in the other 5 parts. A variation of the concept, the 3-slice scaling, consists of a grid of 3 parts in which only the pixels in 2 parts (the edges) are protected, and the pixels in the middle part are repeated.

History and use The concept was first introduced in a consumer application by Macromedia in Flash 8 (2005), and it was available as a feature to scale symbols. Later on, in 2007 Adobe introduced it as a feature in Adobe Fireworks CS3, Adobe Illustrator, and Adobe Flash. Today it is also present as a feature of game development software like Unreal Engine, Bevy, Urho3D, and Unity 3D. The technique can be used to manipulate both bitmap/raster graphics and vector graphics. A current implementation of the 9-slice technique is present on the CSS 3 Backgrounds and Borders spec by using the border-image property.

27-slice scaling The concept used in 9-slice scaling can be extended to 3D, which enables a more natural way of scaling certain 3D meshes. The number 27 is derived by splitting a cuboid into 3 sections on all 3 axes. The general method of scaling remains the same, whereby the 8 corners of the cuboid do not scale, similar to the 4 corners present in 9-slice scaling. The central core scales in 3 dimensions. The 6 faces of the cuboid scale in 2 dimensions. The remaining 12 edge pieces scale in 1 dimension. All of which are relative to the actual scaling applied. A functional implementation is done in Unity as a downloadable package.

References

Illustrations

9-slice scaling: Top: Traditional scaling, corners are distorted. Bottom: 9-slice scaling, corners aren't distorted. Corner pieces (1, 3, 7, and 9) are not scaled, vertical edges (2 and 8) are scaled only horizontally, horizontal edges (4 and 6) are scaled only vertically, and the center piece (5) is scaled both horizontally and vertically.
Top: Traditional scaling, corners are distorted. Bottom: 9-slice scaling, corners aren't distorted. Corner pieces (1, 3, 7, and 9) are not scaled, vertical edges (2 and 8) are scaled only horizontally, horizontal edges (4 and 6) are scaled only vertically, and the center piece (5) is scaled both horizontally and vertically.

Worked examples

Example 1 — a first encounter with 9-slice scaling

Start with the simplest possible case. Write down what 9-slice scaling claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to 9-slice scaling before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about 9-slice scaling ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of 9-slice scaling

In research
9-slice scaling appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses 9-slice scaling in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
9-slice scaling is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer graphics, so understanding it makes those chapters shorter.
In everyday life
Look for 9-slice scaling outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “9-slice scaling” →

How to study 9-slice scaling in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what 9-slice scaling means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain 9-slice scaling out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is 9-slice scaling in simple terms?

9-slice scaling (also known as Scale 9 grid, 9-slicing or 9-patch) is a 2D image resizing technique to proportionally scale an image by splitting it into a grid of nine parts. The key idea is to prevent image scaling distortion by protecting the pixels defined in 4 parts (corners) of the image and…

Why does 9-slice scaling matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study 9-slice scaling?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on 9-slice scaling.

Tags

  • Computer graphics

Keep exploring