Merge: model: is_accessor
[nit.git] / lib / bitmap / test_bitmap.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2015 Budi Kurniawan <budi2020@gmail.com>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # This file tests the Bitmap class in the bitmap module
18 # It has to be called by passing two arguments:
19 #
20 # - An input bitmap file
21 # - An output bitmap file
22 #
23 # It converts the input bitmap to grayscale and save it to the specified
24 # output file. In addition, it creates a blank.bmp file in the current directory.
25 #
26 #
27 # A module for testing the classes in the bitmap module
28 module test_bitmap is test
29
30 import bitmap
31
32 class TestBitmap
33 test
34
35 fun test_grayscale is test do
36 var bitmap = new Bitmap.with_size(400, 300)
37 for y in [0..300] do
38 for x in [0..200] do bitmap.set_pixel(x, y, 0x0077AAAA)
39 end
40 bitmap.grayscale
41 bitmap.save("./blank.bmp")
42 end
43 end