| #Topic Illustrations |
| |
| #Subtopic Image_Info_Color_Type_RGB_565 |
| #Example |
| #Width 415 |
| #Height 250 |
| void draw(SkCanvas* canvas) { |
| canvas->scale(1.25f, 1.25f); |
| SkPaint paint; |
| paint.setAntiAlias(true); |
| paint.setTextSize(10); |
| paint.setTextAlign(SkPaint::kCenter_Align); |
| canvas->drawString("16-bit word", 5 + 20 * 8, 20, paint); |
| canvas->drawString("little endian byte order", 5 + 20 * 4, 85, paint); |
| canvas->drawString("(low bits)", 5 + 20 * 1.5f, 137, paint); |
| canvas->drawString("(high bits)", 5 + 20 * 6.5f, 187, paint); |
| auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void { |
| SkPaint p(paint); |
| p.setColor(SK_ColorRED); |
| SkScalar xPos = 15; |
| int width = n % 32 + 1; |
| int lastN = n > 32 ? 32 : 0; |
| for (; n >= lastN; --n) { |
| for (int i = 0; i <= count; ++i) { |
| int a = width - e[i]; |
| if (a == n || a == n + 1 || a == n - 32 || a == n - 31) { |
| char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'}; |
| canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p); |
| break; |
| } |
| } |
| xPos += 20; |
| } |
| p.setColor(SK_ColorBLACK); |
| for (int i = 0; i < count; ++i) { |
| canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p); |
| } |
| p.setStyle(SkPaint::kStroke_Style); |
| for (int i = 0; i <= count; ++i) { |
| canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p); |
| } |
| for (int i = 0; i < 2; ++i) { |
| canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p); |
| } |
| }; |
| SkScalar edges[] = { 0, 5, 11, 16, |
| 0, 3, 8, |
| 0, 5, 8 }; |
| const char* labels[] = { "red", "green", "blue" }; |
| drawBoxText(&edges[0], &labels[0], 3, 15, 45); |
| drawBoxText(&edges[4], &labels[1], 2, 7, 110); |
| drawBoxText(&edges[7], &labels[0], 2, 7, 160); |
| } |
| ## |
| ## |
| |
| #Subtopic Image_Info_Color_Type_ARGB_4444 |
| #Example |
| #Width 415 |
| #Height 250 |
| void draw(SkCanvas* canvas) { |
| canvas->scale(1.25f, 1.25f); |
| SkPaint paint; |
| paint.setAntiAlias(true); |
| paint.setTextSize(10); |
| paint.setTextAlign(SkPaint::kCenter_Align); |
| canvas->drawString("16-bit word", 5 + 20 * 8, 20, paint); |
| canvas->drawString("little endian byte order", 5 + 20 * 4, 85, paint); |
| auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void { |
| SkPaint p(paint); |
| p.setColor(SK_ColorRED); |
| SkScalar xPos = 15; |
| int width = n % 32 + 1; |
| int lastN = n > 32 ? 32 : 0; |
| for (; n >= lastN; --n) { |
| for (int i = 0; i <= count; ++i) { |
| int a = width - e[i]; |
| if (a == n || a == n + 1 || a == n - 32 || a == n - 31) { |
| char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'}; |
| canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p); |
| break; |
| } |
| } |
| xPos += 20; |
| } |
| p.setColor(SK_ColorBLACK); |
| for (int i = 0; i < count; ++i) { |
| canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p); |
| } |
| p.setStyle(SkPaint::kStroke_Style); |
| for (int i = 0; i <= count; ++i) { |
| canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p); |
| } |
| for (int i = 0; i < 2; ++i) { |
| canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p); |
| } |
| }; |
| SkScalar edges[] = { 0, 4, 8, 12, 16 }; |
| const char* labels[] = { "red", "green", "blue", "alpha" }; |
| drawBoxText(&edges[0], &labels[0], 4, 15, 45); |
| drawBoxText(&edges[0], &labels[2], 2, 7, 110); |
| drawBoxText(&edges[0], &labels[0], 2, 7, 160); |
| } |
| ## |
| ## |
| |
| #Subtopic Image_Info_Color_Type_RGBA_8888 |
| #Example |
| #Width 812 |
| #Height 365 |
| void draw(SkCanvas* canvas) { |
| canvas->scale(1.25f, 1.25f); |
| SkPaint paint; |
| paint.setAntiAlias(true); |
| paint.setTextSize(10); |
| paint.setTextAlign(SkPaint::kCenter_Align); |
| canvas->drawString("32-bit word", 5 + 20 * 16, 20, paint); |
| canvas->drawString("little endian byte order", 5 + 20 * 4, 85, paint); |
| auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void { |
| SkPaint p(paint); |
| p.setColor(SK_ColorRED); |
| SkScalar xPos = 15; |
| int width = n % 32 + 1; |
| int lastN = n > 32 ? 32 : 0; |
| for (; n >= lastN; --n) { |
| for (int i = 0; i <= count; ++i) { |
| int a = width - e[i]; |
| if (a == n || a == n + 1 || a == n - 32 || a == n - 31) { |
| char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'}; |
| canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p); |
| break; |
| } |
| } |
| xPos += 20; |
| } |
| p.setColor(SK_ColorBLACK); |
| for (int i = 0; i < count; ++i) { |
| canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p); |
| } |
| p.setStyle(SkPaint::kStroke_Style); |
| for (int i = 0; i <= count; ++i) { |
| canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p); |
| } |
| for (int i = 0; i < 2; ++i) { |
| canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p); |
| } |
| }; |
| SkScalar edges[] = { 0, 8, 16, 24, 32 }; |
| const char* labels[] = { "alpha", "blue", "green", "red" }; |
| drawBoxText(edges, &labels[0], 4, 31, 45); |
| drawBoxText(edges, &labels[3], 1, 7, 110); |
| drawBoxText(edges, &labels[2], 1, 7, 160); |
| drawBoxText(edges, &labels[1], 1, 7, 210); |
| drawBoxText(edges, &labels[0], 1, 7, 260); |
| } |
| ## |
| ## |
| |
| #Subtopic Image_Info_Color_Type_RGB_888 |
| #Example |
| #Width 812 |
| #Height 365 |
| void draw(SkCanvas* canvas) { |
| canvas->scale(1.25f, 1.25f); |
| SkPaint paint; |
| paint.setAntiAlias(true); |
| paint.setTextSize(10); |
| paint.setTextAlign(SkPaint::kCenter_Align); |
| canvas->drawString("32-bit word", 5 + 20 * 16, 20, paint); |
| canvas->drawString("little endian byte order", 5 + 20 * 4, 85, paint); |
| auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void { |
| SkPaint p(paint); |
| p.setColor(SK_ColorRED); |
| SkScalar xPos = 15; |
| int width = n % 32 + 1; |
| int lastN = n > 32 ? 32 : 0; |
| for (; n >= lastN; --n) { |
| for (int i = 0; i <= count; ++i) { |
| int a = width - e[i]; |
| if (a == n || a == n + 1 || a == n - 32 || a == n - 31) { |
| char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'}; |
| canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p); |
| break; |
| } |
| } |
| xPos += 20; |
| } |
| p.setColor(SK_ColorBLACK); |
| for (int i = 0; i < count; ++i) { |
| canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p); |
| } |
| p.setStyle(SkPaint::kStroke_Style); |
| for (int i = 0; i <= count; ++i) { |
| canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p); |
| } |
| for (int i = 0; i < 2; ++i) { |
| canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p); |
| } |
| }; |
| SkScalar edges[] = { 0, 8, 16, 24, 32 }; |
| const char* labels[] = { "(unused)", "blue", "green", "red" }; |
| drawBoxText(edges, &labels[0], 4, 31, 45); |
| drawBoxText(edges, &labels[3], 1, 7, 110); |
| drawBoxText(edges, &labels[2], 1, 7, 160); |
| drawBoxText(edges, &labels[1], 1, 7, 210); |
| drawBoxText(edges, &labels[0], 1, 7, 260); |
| } |
| ## |
| ## |
| |
| #Subtopic Image_Info_Color_Type_BGRA_8888 |
| #Example |
| #Width 812 |
| #Height 365 |
| void draw(SkCanvas* canvas) { |
| canvas->scale(1.25f, 1.25f); |
| SkPaint paint; |
| paint.setAntiAlias(true); |
| paint.setTextSize(10); |
| paint.setTextAlign(SkPaint::kCenter_Align); |
| canvas->drawString("32-bit word", 5 + 20 * 16, 20, paint); |
| canvas->drawString("little endian byte order", 5 + 20 * 4, 85, paint); |
| auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void { |
| SkPaint p(paint); |
| p.setColor(SK_ColorRED); |
| SkScalar xPos = 15; |
| int width = n % 32 + 1; |
| int lastN = n > 32 ? 32 : 0; |
| for (; n >= lastN; --n) { |
| for (int i = 0; i <= count; ++i) { |
| int a = width - e[i]; |
| if (a == n || a == n + 1 || a == n - 32 || a == n - 31) { |
| char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'}; |
| canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p); |
| break; |
| } |
| } |
| xPos += 20; |
| } |
| p.setColor(SK_ColorBLACK); |
| for (int i = 0; i < count; ++i) { |
| canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p); |
| } |
| p.setStyle(SkPaint::kStroke_Style); |
| for (int i = 0; i <= count; ++i) { |
| canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p); |
| } |
| for (int i = 0; i < 2; ++i) { |
| canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p); |
| } |
| }; |
| SkScalar edges[] = { 0, 8, 16, 24, 32 }; |
| const char* labels[] = { "alpha", "red", "green", "blue" }; |
| drawBoxText(edges, &labels[0], 4, 31, 45); |
| drawBoxText(edges, &labels[3], 1, 7, 110); |
| drawBoxText(edges, &labels[2], 1, 7, 160); |
| drawBoxText(edges, &labels[1], 1, 7, 210); |
| drawBoxText(edges, &labels[0], 1, 7, 260); |
| } |
| ## |
| ## |
| |
| #Subtopic Image_Info_Color_Type_RGBA_1010102 |
| #Example |
| #Width 812 |
| #Height 380 |
| void draw(SkCanvas* canvas) { |
| canvas->scale(1.25f, 1.25f); |
| SkPaint paint; |
| paint.setAntiAlias(true); |
| paint.setTextSize(10); |
| paint.setTextAlign(SkPaint::kCenter_Align); |
| canvas->drawString("32-bit word", 5 + 20 * 16, 20, paint); |
| canvas->drawString("little endian byte order", 5 + 20 * 4, 85, paint); |
| canvas->drawString("(low bits)", 5 + 20 * 4, 137, paint); |
| canvas->drawString("(low bits)", 5 + 20 * 3, 187, paint); |
| canvas->drawString("(high bits)", 5 + 20 * 7, 187, paint); |
| canvas->drawString("(low bits)", 5 + 20 * 2, 237, paint); |
| canvas->drawString("(high bits)", 5 + 20 * 6, 237, paint); |
| canvas->drawString("(high bits)", 5 + 20 * 5, 287, paint); |
| auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void { |
| SkPaint p(paint); |
| p.setColor(SK_ColorRED); |
| SkScalar xPos = 15; |
| int width = n % 32 + 1; |
| int lastN = n > 32 ? 32 : 0; |
| for (; n >= lastN; --n) { |
| for (int i = 0; i <= count; ++i) { |
| int a = width - e[i]; |
| if (a == n || a == n + 1 || a == n - 32 || a == n - 31) { |
| char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'}; |
| canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p); |
| break; |
| } |
| } |
| xPos += 20; |
| } |
| p.setColor(SK_ColorBLACK); |
| for (int i = 0; i < count; ++i) { |
| canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p); |
| } |
| p.setStyle(SkPaint::kStroke_Style); |
| for (int i = 0; i <= count; ++i) { |
| canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p); |
| } |
| for (int i = 0; i < 2; ++i) { |
| canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p); |
| } |
| }; |
| SkScalar edges[] = { 0, 2, 12, 22, 32, |
| 0, 8, |
| 0, 6, 8, |
| 0, 4, 8, |
| 0, 2, 8 |
| }; |
| const char* labels[] = { "alpha", "blue", "green", "red" }; |
| drawBoxText(&edges[0], &labels[0], 4, 31, 45); |
| drawBoxText(&edges[5], &labels[3], 1, 7, 110); |
| drawBoxText(&edges[7], &labels[2], 2, 7, 160); |
| drawBoxText(&edges[10], &labels[1], 2, 7, 210); |
| drawBoxText(&edges[13], &labels[0], 2, 7, 260); |
| } |
| ## |
| ## |
| |
| #Subtopic Image_Info_Color_Type_RGB_101010 |
| #Example |
| #Width 812 |
| #Height 380 |
| void draw(SkCanvas* canvas) { |
| canvas->scale(1.25f, 1.25f); |
| SkPaint paint; |
| paint.setAntiAlias(true); |
| paint.setTextSize(10); |
| paint.setTextAlign(SkPaint::kCenter_Align); |
| canvas->drawString("32-bit word", 5 + 20 * 16, 20, paint); |
| canvas->drawString("little endian byte order", 5 + 20 * 4, 85, paint); |
| canvas->drawString("(low bits)", 5 + 20 * 4, 137, paint); |
| canvas->drawString("(low bits)", 5 + 20 * 3, 187, paint); |
| canvas->drawString("(high bits)", 5 + 20 * 7, 187, paint); |
| canvas->drawString("(low bits)", 5 + 20 * 2, 237, paint); |
| canvas->drawString("(high bits)", 5 + 20 * 6, 237, paint); |
| canvas->drawString("(high bits)", 5 + 20 * 5, 287, paint); |
| auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void { |
| SkPaint p(paint); |
| p.setColor(SK_ColorRED); |
| SkScalar xPos = 15; |
| int width = n % 32 + 1; |
| int lastN = n > 32 ? 32 : 0; |
| for (; n >= lastN; --n) { |
| for (int i = 0; i <= count; ++i) { |
| int a = width - e[i]; |
| if (a == n || a == n + 1 || a == n - 32 || a == n - 31) { |
| char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'}; |
| canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p); |
| break; |
| } |
| } |
| xPos += 20; |
| } |
| p.setColor(SK_ColorBLACK); |
| for (int i = 0; i < count; ++i) { |
| canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p); |
| } |
| p.setStyle(SkPaint::kStroke_Style); |
| for (int i = 0; i <= count; ++i) { |
| canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p); |
| } |
| for (int i = 0; i < 2; ++i) { |
| canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p); |
| } |
| }; |
| SkScalar edges[] = { 0, 2, 12, 22, 32, |
| 0, 8, |
| 0, 6, 8, |
| 0, 4, 8, |
| 0, 2, 8 |
| }; |
| const char* labels[] = { "unused", "blue", "green", "red" }; |
| drawBoxText(&edges[0], &labels[0], 4, 31, 45); |
| drawBoxText(&edges[5], &labels[3], 1, 7, 110); |
| drawBoxText(&edges[7], &labels[2], 2, 7, 160); |
| drawBoxText(&edges[10], &labels[1], 2, 7, 210); |
| drawBoxText(&edges[13], &labels[0], 2, 7, 260); |
| } |
| ## |
| ## |
| |
| #Subtopic Image_Info_Color_Type_RGBA_F16 |
| #Example |
| #Width 812 |
| #Height 685 |
| void draw(SkCanvas* canvas) { |
| canvas->scale(1.25f, 1.25f); |
| SkPaint paint; |
| paint.setAntiAlias(true); |
| paint.setTextSize(10); |
| paint.setTextAlign(SkPaint::kCenter_Align); |
| canvas->drawString("64-bit word", 5 + 20 * 16, 20, paint); |
| canvas->drawString("little endian byte order", 5 + 20 * 4, 135, paint); |
| for (int i = 0; i < 4; ++i) { |
| canvas->drawString("(low bits)", 5 + 20 * 4, 187 + i * 100, paint); |
| canvas->drawString("(high bits)", 5 + 20 * 4, 237 + i * 100, paint); |
| } |
| auto drawBoxText = [=](SkScalar e[], const char* s[], int count, int n, SkScalar yPos) -> void { |
| SkPaint p(paint); |
| p.setColor(SK_ColorRED); |
| SkScalar xPos = 15; |
| int width = n % 32 + 1; |
| int lastN = n > 32 ? 32 : 0; |
| for (; n >= lastN; --n) { |
| for (int i = 0; i <= count; ++i) { |
| int a = width - e[i]; |
| if (a == n || a == n + 1 || a == n - 32 || a == n - 31) { |
| char num[3] = {(char) ('0' + n / 10), (char) ('0' + n % 10), '\0'}; |
| canvas->drawString(n >= 10 ? num : &num[1], xPos, yPos - 5, p); |
| break; |
| } |
| } |
| xPos += 20; |
| } |
| p.setColor(SK_ColorBLACK); |
| for (int i = 0; i < count; ++i) { |
| canvas->drawString(s[i], 5 + (e[i] + e[i + 1]) * 10, yPos + 10, p); |
| } |
| p.setStyle(SkPaint::kStroke_Style); |
| for (int i = 0; i <= count; ++i) { |
| canvas->drawLine(5 + e[i] * 20, yPos, 5 + e[i] * 20, yPos + 15, p); |
| } |
| for (int i = 0; i < 2; ++i) { |
| canvas->drawLine(5 + e[0] * 20, yPos + i * 15, 5 + e[count] * 20, yPos + i * 15, p); |
| } |
| }; |
| SkScalar edges[] = { 0, 16, 32, |
| 0, 8 |
| }; |
| const char* labels[] = { "alpha", "blue", "green", "red" }; |
| drawBoxText(&edges[0], &labels[0], 2, 63, 45); |
| drawBoxText(&edges[0], &labels[2], 2, 31, 95); |
| drawBoxText(&edges[3], &labels[3], 1, 7, 160); |
| drawBoxText(&edges[3], &labels[3], 1, 7, 210); |
| drawBoxText(&edges[3], &labels[2], 1, 7, 260); |
| drawBoxText(&edges[3], &labels[2], 1, 7, 310); |
| drawBoxText(&edges[3], &labels[1], 1, 7, 360); |
| drawBoxText(&edges[3], &labels[1], 1, 7, 410); |
| drawBoxText(&edges[3], &labels[0], 1, 7, 460); |
| drawBoxText(&edges[3], &labels[0], 1, 7, 510); |
| } |
| ## |
| ## |
| |
| #Topic Illustrations ## |