CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Other Programming > Assembly
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Assembly Questions and Answers for Assembly here!

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old April 27th, 2005, 09:22 AM
    eternallove29 eternallove29 is offline
    Junior Member
     
    Join Date: Apr 2005
    Posts: 4
    eternallove29 is an unknown quantity at this point (<10)
    BMP Image

    Hello,

    Does anyone know how to load a BMP file in ASSEMBLY?

    If any of you have worked on Image Processing, then it'd be really helpful.. !

    Thanks

    ~Techie Girl
    Reply With Quote
      #2    
    Old April 30th, 2005, 02:41 PM
    Hobson's Avatar
    Hobson Hobson is offline
    Senior Member
     
    Join Date: Dec 2004
    Location: Poland
    Posts: 1,163
    Hobson has much to be proud of (1500+)Hobson has much to be proud of (1500+)Hobson has much to be proud of (1500+)Hobson has much to be proud of (1500+)Hobson has much to be proud of (1500+)Hobson has much to be proud of (1500+)Hobson has much to be proud of (1500+)Hobson has much to be proud of (1500+)Hobson has much to be proud of (1500+)Hobson has much to be proud of (1500+)Hobson has much to be proud of (1500+)
    Re: BMP Image

    Hi
    Why do you need to read file using assembly? Isn't it possible to read it using some higher-level stuff, and do time-consuming processing with assembly routines?

    Hob
    __________________
    B+!
    'There is no cat' - A. Einstein

    Use [code] [/code] tags!

    Did YOU share your photo with us at CG Members photo gallery ?
    Reply With Quote
      #3    
    Old May 26th, 2005, 05:28 PM
    eternallove29 eternallove29 is offline
    Junior Member
     
    Join Date: Apr 2005
    Posts: 4
    eternallove29 is an unknown quantity at this point (<10)
    Re: BMP Image

    I apologize for the late reply.

    I know High level interface would solve my problem. But it's the part of my project , so I have to work on BMP files through ASM.

    Can somebody fix this code written in Assembly Language?
    It works for BMP files.....i.e. it first checks for the valid BMP file n then load it..

    Please have a look.

    .model small
    .stack 100h
    .186
    .code

    PUBLIC ShowBMP

    ShowBMP proc
    pusha
    call OpenInputFile
    jc FileErr
    mov bx,ax
    call ReadHeader
    jc InvalidBMP
    call ReadPal
    push es
    call InitVid
    call SendPal
    call LoadBMP
    call CloseFile
    pop es
    jmp ProcDone

    FileErr:
    mov ah,9
    mov dx,offset msgFileErr
    int 21h
    jmp ProcDone

    InvalidBMP:
    mov ah,9
    mov dx,offset msgInvBMP
    int 21h

    ProcDone:
    popa
    ret
    ShowBMP endp

    CheckValid proc
    clc
    mov si,offset Header
    mov di,offset BMPStart
    mov cx,2

    CVloop:
    mov al,[si]
    mov dl,[di]
    cmp al,dl
    jne NotValid
    inc si
    inc di
    loop CVloop
    jmp CVdone

    NotValid:
    stc

    CVdone:
    ret
    CheckValid endp

    GetBMPInfo proc
    mov ax,header[0ah]
    sub ax,54
    shr ax,2
    mov PalSize,ax
    mov ax,header[12h]
    mov BMPWidth,ax
    mov ax,header[16h]
    mov BMPHeight,ax
    ret
    GetBMPInfo endp

    InitVid proc
    mov ax,13h
    int 10h
    push 0a00h
    pop es
    ret
    InitVid endp

    LoadBMP proc
    mov cx,BMPHeight

    ShowLoop:
    push cx
    mov di,cx
    shl cx,6
    shl di,8
    add di,cx

    mov ah,3fh
    mov cx,BMPWidth
    mov dx,offset Scrline
    int 21h

    cld
    mov cx,BMPWidth
    mov si,offset Scrline
    rep movsb

    pop cx
    loop Showloop
    ret
    LoadBMP endp

    ReadHeader proc
    mov ah,3fh
    mov cx,54
    mov dx,offset Header
    int 21h

    call CheckValid
    jc RHdone
    call GetBMPinfo

    RHdone:
    ret
    ReadHeader endp

    ReadPal proc
    mov ah,3fh
    mov cx,PalSize
    shl cx,2

    mov dx,offset palbuff
    int 21h
    ret
    ReadPal endp

    OpenInputFile proc
    mov dx,offset My_file
    mov ah,4Dh
    mov al,1
    int 21h

    mov handle,ax
    OpenInputFile endp


    CloseFile proc
    mov bx,Handle
    mov ah,3Eh
    int 21h

    CloseFile endp

    SendPal proc
    mov si,offset palBuff
    mov cx,PalSize
    mov dx,3c8h
    mov al,0
    out dx,al
    inc dx

    sndLoop:
    mov al,[si+2]
    shr al,2

    out dx,al
    mov al,[si+1]
    shr al,2
    out dx,al
    mov al,[si]
    shr al,2
    out dx,al

    add si,4

    loop sndLoop
    ret
    SendPal endp

    .data
    My_file db 'c:\new.bmp',0
    Handle dw ?
    Header label word
    HeadBuff db 54 dup('H')
    palBuff db 1024 dup('P')
    Scrline db 320 dup(0)
    BMPStart db 'BM'
    PalSize dw ?
    BMPHeight dw ?
    BMPWidth dw ?
    msgInvBMP db "Not a valid BMP file.",7,0dh,0ah,24
    msgFileErr db "Error opening file.",7,0dh,0ah,24
    end

    If anyone can help in fixing the errors then it'd be highly appreciated.

    Thanks

    ~Techie Girl
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Other Programming > Assembly


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 10:24 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009