Bitmap: Difference between revisions
m
→{{header|Wren}}: Changed to Wren S/H
m (→{{header|Wren}}: Changed to Wren S/H) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 3,634:
Use getPixels to retrieve the colour of a pixel. As with setPixels, this function is optimised to retrieve one row at a time as an array of colour values.
<syntaxhighlight lang="maxscript">local myPixel = getPixels myBitmap [256, 256] 1</syntaxhighlight>
=={{header|MiniScript}}==
This GUI implementation is for use with [http://miniscript.org/MiniMicro Mini Micro].
<syntaxhighlight lang="miniscript">
// MiniMicro version of MiniScript has all the
// necessary methods built-in to complete this task.
width = 256
height = 256
colr = color.aqua
// Create the image with specified width/heigh. With
// no parameters, it defaults width/height to 64 and
// color to black
img = Image.create(width, height, colr)
// Create a diagonal line of multiple colors. Uses
// Cartesian coordinates so (0, 0) is lower left corner.
for i in range(0, 255)
img.setPixel i, i, color.rgb(i, i, i)
end for
// Get pixel color as RGBA hex values
print "Color at pixel (100, 100): " + img.pixel(100, 100)
print "Color at pixel (0, 0): " + img.pixel(0, 0)
print "Color at pixel (127, 127): " + img.pixel(127, 127)
print "Color at pixel (255, 255): " + img.pixel(255, 255)
// Display the image, resizing it to 127 x 127
gfx.drawImage img, 0, 0, 127, 127
// Save the file - accepted file extensions:
// tga, jpg, jpeg, and png (retains transparency)
// Optional third parameter is JPG compression quality.
file.saveImage "/usr/test.png", img
</syntaxhighlight>
=={{header|Modula-3}}==
Since this code is for use with other tasks, it uses an interface as well as the implementation module.
Line 4,557 ⟶ 4,593:
The image (raster) created was also written to a file ('''image.PPM''') to show verification of the image.
<syntaxhighlight lang="rexx">/*REXX program demonstrates how to process/display
sWidth = 500; sHeight= 500 /*the screen width and height in pixels*/
call RGBfill red /*set the entire image to red. */▼
Call RGBfill
bin3V = left(binV, 8) substr(binV, 9, 8) right(binV, 8)▼
Say xy ' pixel in binary: ' bin3V /*show again,but with spaces. */
Say xy ' pixel in hex: ' hex3V /*show again,but with spaces. */
/* ?¦¦¦¦¦¦¦¦ not part of this task.*/
say 'The file ' outFN".PPM was created." /*inform user that a file was created. */▼
▲
/*---------------------------------------------------------------------*/
RGBget: parse arg px,py; return @.px.py /*get a pixel's color. */▼
RGBset: Parse arg px,py,psep; pixel.px.py=psep; Return /*set a pixel */
/*---------------------------------------------------------------------*/
PPMwrite: Parse arg oFN,width,height
oFID= oFN'.PPM' /* fileID
sep='9'x; /* separator
maxcol=255
Call charout oFID,,1
Call charout oFID,'P6'width||sep||height||sep||maxcol||sep /* header */
Do i=1 To width
call charout oFID; return /*close the output file just to be safe*/</syntaxhighlight>▼
Do j=1 To height;
Call charout oFID,pixel.i.j
End
End
Return</syntaxhighlight>
{{out|output}}
<pre>
Line 5,334 ⟶ 5,376:
{{libheader|DOME}}
The above library's ImageData class fits the bill here (version 1.3.0 or later).
<syntaxhighlight lang="
import "dome" for Window
Line 5,373 ⟶ 5,415:
Color (#29ADFFFF)
</pre>
=={{header|Xojo}}==
|