Weekly Qbasic and Qb64 Lesson Topics
January 21, 2018, 12:53:09 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

Making monochrome images


Pages: [1]
  Print  
Author Topic: Making monochrome images  (Read 290 times)
Unseen Machine
Post Demos
*
Posts: 46


« on: April 27, 2011, 08:49:53 am »

Converted from the GDK function GDK_ApplyMonoFilter, this version can be used on any image.

Code:
SCREEN _NEWIMAGE(800, 600, 32)

image& = _LOADIMAGE("qblogo.png")
ConvertImage_Mono image&, _RGB(0, 0, 0)
_PUTIMAGE (0, 0), image&


SUB ConvertImage_Mono (Image AS LONG, Alpha&)
OldSource& = _SOURCE
_SOURCE Image
_DEST Image
w% = _WIDTH(Image)
h% = _HEIGHT(Image)
FOR i% = 0 TO w%
  FOR j% = 0 TO h%
    m& = POINT(i%, j%)
    IF m& <> Alpha& THEN
      clrsum% = (INT((_BLUE(m&) / 100) * 11) + INT((_RED(m&) / 100) * 39) + INT((_GREEN(m&) / 100) * 50))
      IF clrsum% > 0 AND clrsum% < 255 THEN
        PSET (i%, j%), _RGB(clrsum%, clrsum%, clrsum%)
      END IF
    END IF
  NEXT
NEXT
_SOURCE OldSource&
_DEST 0
END SUB

Report Spam   Logged

Social Buttons

OlDosLover
Guest
« Reply #1 on: April 27, 2011, 08:58:31 am »

Hi all,
    Welcome to the forum unseen. This looks a good program , thanks for sharing. Would like to point out that this site has Private Messageing and Image posting , and would like to invite you to use either as needed.
OlDosLover.
Report Spam   Logged
OlDosLover
Guest
« Reply #2 on: April 27, 2011, 09:27:23 am »

Hi all,
    Inspired by unseen's post a little effect that tricks my eyes.
Code:
REM
SCREEN _NEWIMAGE(800, 600, 32)

image& = _LOADIMAGE("qblogo.png")
effect& = _LOADIMAGE("qblogo.png")

ConvertImage_Mono image&, _RGB(0, 0, 0)

x% = 0: y% = 0: z% = 50
DO
  _LIMIT 30
  _PUTIMAGE (0, 0), image&
  _PUTIMAGE (x%, y%)-(x% + z%, y% + z%), effect&, 0, (x%, y%)-(x% + z%, y% + z%)
  _DISPLAY
  x% = x% + 1: IF x% >= 158 - z% THEN x% = 0
  y% = y% + 1: IF y% >= 127 - z% THEN y% = 0
LOOP UNTIL _KEYDOWN(27)
SLEEP
SYSTEM


SUB ConvertImage_Mono (Image AS LONG, Alpha&)
OldSource& = _SOURCE
_SOURCE Image
_DEST Image
w% = _WIDTH(Image)
h% = _HEIGHT(Image)
FOR i% = 0 TO w%
  FOR j% = 0 TO h%
    m& = POINT(i%, j%)
    IF m& <> Alpha& THEN
      clrsum% = (INT((_BLUE(m&) / 100) * 11) + INT((_RED(m&) / 100) * 39) + INT((_GREEN(m&) / 100) * 50))
      IF clrsum% > 0 AND clrsum% < 255 THEN
        PSET (i%, j%), _RGB(clrsum%, clrsum%, clrsum%)
      END IF
    END IF
  NEXT
NEXT
_SOURCE OldSource&
_DEST 0
END SUB
Thanks unseen.
OlDosLover.
« Last Edit: April 27, 2011, 10:20:31 pm by OlDosLover » Report Spam   Logged
Unseen Machine
Post Demos
*
Posts: 46


« Reply #3 on: April 27, 2011, 10:05:53 am »

Nice, i never even thought of that!
Report Spam   Logged
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #4 on: April 27, 2011, 07:53:39 pm »

Hi, Unseen, thanks for all the stuff you posted, I didnt reply to each one,
But do appreciate them all,..
 All though everyone here probably has the qblogo image, partly just to demo this, anyone that wants to run the above code, needs the attached image,  or they can change the image file name in the code, for any image,..( I think, or dose the size matter, if so it ,the image,would need edited to the corect size, or the code),... any way here is the image attcahed.
Report Spam   Logged


Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Buy traffic for your forum/website
traffic-masters
Powered by SMF | SMF © 2016, Simple Machines